Reputation: 33579
Where are static data members stored? Is there some kind of static members table (as in "virtual methods table")?
I've performed an experiment - seems like static members don't affect sizeof()
at all. Does it mean all references to static members are converted to a fixed address?
Upvotes: 8
Views: 219
Reputation:
Static members in C++ are implemented in exactly the same way as static non-members in both C++ and C. There is no "static member table".
Upvotes: 4
Reputation: 272507
The C++ standard doesn't enforce a particular implementation. But typically static class members will be implemented in a similar fashion to "free" statics.
However, your observation that sizeof
shouldn't be affected by static members is correct.
Upvotes: 13