Possible Duplicate:
Why is a class allowed to have a static member of itself, but not a non-static member?
This is invalid piece of code
struct a{
a mem; //Invalid as the compiler does not know how much memory to allocate
};
But this is valid:
class Date{
int d,m,y;
static Date Default_date; //Valid
};
How is the compiler able to know here how much memory to allocate here before the Date datatype is not even defined properly!!
Is this different from other static definitions in some sense???
The static members is not stored inside the class, so its size doesn’t affect the total size of the class.
You will have to define the static member somewhere else, perhaps in a .cpp file. At that time the compiler will have to know the size of the class.