### Scope of Class Names

A class declaration introduces the class name into the scope where it is declared. Any class, object, function or other declaration of that name in an enclosing scope is hidden. If a class name is declared in a scope where an object, function, or enumerator of the same name is also declared, you can only refer to the class by using the elaborated type specifier. The class key (class, struct, or union) must precede the class name to identify it.

For example:

    // This example shows the scope of class names.

    class x { int a; };            // declare a class type class-name

    x xobject;                     // declare object of class type x

    int x(class x*)                // redefine x to be a function
    {return 0;}                    // use class-key class to define
                                   // a pointer to the class type x
                                   // as the function argument

    void main()
    {
          class x* xptr;           // use class-key class to define
                                   // a pointer to class type x
          xptr = &xobject;         // assign pointer
          x(xptr);                 // call function x with pointer to class x
    }

An elaborated type specifier can be used in the declaration of objects and functions.

An elaborated type specifier can also be used in the incomplete declaration of a class type to reserve the name for a class type within the current scope.

Incomplete Class Declarations
Nested Classes
Local Classes
Local Type Names
Class Names
Declaring Class Objects