0
Memory of static data memeber of a class
Class A { public: static int a; int b; }; int main() { A obj; cout << sizeof (A); cout << sizeof (obj); return 0; } Question is that output of above two sizeof is 4... Size of obj is as expected as one int is static and other is non static... Why size of class is also 4??? Where does and when memory of static variable is consumed as it is not associated with objects..
2 Answers
+ 4
Static members of a class are still part of / can still be invoked using the instance of the class.
0
But memory of those variable is not reflected either in class size or object size