Static Data Members and ENUMS
- When a class contains an enum data member, and a public
enum list, the enum data member may be assigned values
within
member functions by specifying the enumerated values. However, if the
enum member is assigned values outside the scope of the class,
the
enumerated list values must be qualified by the class name and the scope
resolution operator. Example...
- Static data members and member functions are shared by all objects
of a class. In other words, static data and functions are not members
of any instance, instead they belong to the entire class. This means
that it is not necessary to instantiate an object in order to access
a static data member of a class. Static data members must be initialized
outside the class definition block and any other function block. Static
member functions can only operate on static data members. A typical use
of
static methods is to implement a class-wide utility, and standard
application
of a static data member is to count the number of active objects of a
class.
Example...
Back to Previous Page
Document:
Local Date:
Last Modified On: