Jump to content

Static variable

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Lhoaner (talk | contribs) at 16:05, 19 February 2005 (Static Variables). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Each object of a class has its own copy of all the instance variables of the class. However, in certain cases, all class objects should share only one copy of a particular variable. Such variables are called static variables. A program contains only one copy of each of a class's static variables in memory, no matter how many objects of the class have been instantiated. A static variable represents class-wide information, all class objects share the same static data item.