### Local Classes

A local class is declared within a function definition. The local class is in the scope of the enclosing function scope. Declarations in a local class can only use type names, enumerations, static variables from the enclosing scope, as well as external variables and functions.

Member functions of a local class have to be defined within their class definition. Member functions of a local class must be inline functions. Like all member functions, those defined within the scope of a local class do not need the keyword inline.

A local class cannot have static data members. In the following example , an attempt to define a static member of a local class causes an error :

    void f()
    {
        class local
        {
           int f();              // error, local class has noninline
                                 // member function
           int g() {return 0;}   // valid, inline member function
           static int a;         // error, static is not allowed for
                                 // local class
           int b;                // valid, nonstatic variable
        };
    }
    //      . . .

An enclosing function has no special access to members of the local class .

Scope of Class Names

Examples of Local Classes
Function Scope
Inline Member Functions
Inline Specifiers
Local Type Names