Is this legal C++?
struct foo
{
int a[100];
int b[sizeof(a) / sizeof(a[0])];
};
GCC 4.6 accepts it, but MSVC 2012 doesn\'t. It seems li
This was illegal in C++03 because these members are nonstatic datamembers.
Starting from C++11 this is legal since in an unevaluated operand you can use nonstatic datamembers without having a corresponding object.
Try this: This is a workaround for MSVC 2010 and MSVC 2012
struct Aoo
{
typedef int ArrayType;
ArrayType a[100];
};
struct foo : public Aoo
{
enum {bSize = sizeof(Aoo) / sizeof(Aoo::ArrayType)};
int b[bSize];
};