class base {
public:
base a;
};
It gives compilation error.
class base {
public:
static base a;
};
whereas this code does not give compilation error
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because
staticclass members are not stored in the class instance, that’s why astaticwould work.Storing an object inside another object of the same type would break the runtime – infinite size, right?
What would
sizeofreturn? The size of the object needs to be known by the compiler, but since it contains an object of the same type, it doesn’t make sense.