Class Names

A class name is a unique identifier that becomes a reserved word within its scope. Once a class name is declared , it hides other declarations of the same name within the enclosing scope.

If a class name is declared in the same scope as a function, enumerator, or object with the same name, that class can be referred to by using an elaborated type specifier. In the following example, the elaborated type specifier is used to refer to the class print that is hidden by the later definition of the function print():

class print
{
      /* definition of class print */
};
void print (class print*);       // redefine print as a function
//      .                        // prefix class-name by class-key
//      .                        // to refer to class print
//      .
void main ()
{
      class print* paper;        // prefix class-name by class-key
                                 // to refer to class print
      print(paper);              // call function print
}

You can use an elaborated type specifier with a class name to declare a class.

You can also qualify type names to refer to hidden type names in the current scope. You can reduce complex class name syntax by using a typedef to represent a nested class name.



Scope of Class Names


Declaring Class Objects
Nested Classes


Example of Using a typedef for a Class Name