CodeClerks

Static Data Members in class



Write the reason you're deleting this FAQ

Static Data Members in class

A data member of a class can be qualified as static. The properties of a static member variable are similar to that of a C static variable. A static member variable has certain special characteristics. These are:

• It is initialized to zero when the first object of its class is created. No other initialization is permitted.
• Only one copy of that member is created for object of its class is created. NO other initialization objects of that class, only matter how many objects are crated.
• It is visible only within the class, but its lifetime is the entire program.

Static variables are normally used to maintain values common to the entire class. For example, a static data member can be used as a counter that records the occurrences of all the objects.

Comments

Please login or sign up to leave a comment

Join