KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Possible Duplicate: Do static members of a class occupy memory if no object of that class is created? Memory Allocation of Static Members in a Class "A class is not considered defined untill its class body is complete, a class can not have data members of its own type. A class can have data members that are pointers/reference to its own type." C++ Primer (Lippman Lajoie) Makes sense. But why is this allowed then ? class justAClass { public : justAClass(); private : static justAClass justAMember; } For pointers it is understandable. But how will this above thing work ? How will i ever decide the size for object of such a class ? Isnt it a recursive case (with no base condition) to have a member of its own type, even if it is static ?
Tags (comma-separated)
Save Edits
Cancel