Access rules for accessing static variable are
- It is initialized to zero when the first object of its class is created. No other initialization is permitted.
- Only the copy of that member is created for the entire class and is shared by all the objects of that class, no matter how many objects are created.
- It is visible only within the class, but its lifetime is the entire program.
Access rules for accessing static member functions are
- A static function can have access to only other static members(functions or variables) declared in the same class.
- A static member function can be called using the class name(instead of its objects).
|