Declaring Class Objects

A class declaration creates a unique type class name .

A class specifier is used to declare a class. Once a class specifier has been seen and its members declared, a class is considered to be defined even if the member functions of that class are not yet defined . A class specifier has the following form:

>>----class-----class_name-------------------{-------------------}--><
    |-struct-|              \-:base_class-/     \-member_list-/
    \-union--/

The member_list is optional. It specifies the class members, both data and functions, of the class class_ name. If the member_list of a class is empty, objects of that class have a nonzero size. You can use a class_name within the member _list of the class specifier itself as long as the size of the class is not required. For more information, see Class Member Lists.

The base_class is optional. It specifies the base class or classes from which the class class_name inherits members. If the base_class is not empty, the class class_name is called a derived class.

The declarator for a class variable declared with the class, struct, or union keyword is an identifier. If the symbol * precedes the identifier, the identifier names a pointer to a class of the specified data type. If ** precedes the identifier, the identifier names a pointer to a pointer to a class of the specified data type.

If a constant expression enclosed in [ ] (brackets) follows the identifier, the identifier names an array of classes of the specified data type. If * precedes the identifier and a constant expression enclosed in [ ] follows the identifier, the identifier names an array of pointers to classes of the specified data type.



Scope of Class Names


Array
Class Names
Class Member Lists
Derivation
Pointer