### Class Member Lists

An optional member list declares sub-objects called class members. Class members can be data, functions, classes, enumeration, bit fields, and typedef names. A member list is the only place you can declare class members. Friend declarations are not class members but must appear in member lists.

The member list follows the class name and is placed between braces. It can contain access specifiers, member declarations, and member definitions.

You can access members by using the class access . (dot) and -> ( arrow) operators.

An access specifier is one of public, private, or protected.

A member declaration declares a class member for the class containing the declaration.

A member declaration that is a qualified name followed by a ; (semicolon) is used to restore access to members of base classes.

A member declarator declares an object, function, or type within a declaration. It cannot contain an initializer. You can initialize a member by using a constructor or, if the member belongs to an aggregate class, by using a brace initializer list (a list surrounded by braces { }) in the declarator list. You must explicitly initialize a class containing constant or reference members with a brace initializer list or explicitly with a constructor.

A member declarator of the form:

          [identifier] : constant-expression

specifies a bit field.

A pure specifier ( = 0) indicates that a function has no definition. It is only used with virtual member functions and replaces the function definition of a member function in the member list.

You can use the storage-class specifier static (but not extern, auto or register) in a member list.

The order of mapping of class members in a member list is implementation dependent. For the IBM C and C++ Compilers, class members are allocated in the order they are declared.

Storage Class Specifiers

Member Access
Dot Operator
Arrow Operator
Declaring Class Objects
Access Declarations
Initialization by Constructor
Virtual Functions
Initializers