<<< | Index | >>> |
Class members may be declared static
Static data members belong to the class, not to any object...
...so they don't take up space in objects.
All objects share the same variable, like a global, but in the class scope:
// point.h class Point { static int m_x_origin; static int m_y_origin; int m_x; int m_y; //... }; // point.cpp: int Point::m_x_origin = 0; // initialization of private (!) static members int Point::m_y_origin = 0;
<<< | Index | >>> |