Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Elaborated Type Specifiers

An elaborated type specifier is a type name preceded by either the class, struct, enum, or union keyword.

class identifier 
struct identifier 
enum identifier 
union identifier

An elaborated type specifier is used either for emphasis, or to reveal a type name that is hidden by the declaration of a variable with the same name in the same scope.

The following statement declares the Window identifier as a class name. This syntax is used for forward declaration of classes. For more information about class names, see Class Names.

class Window;

If a name is declared using the union keyword, it must also be defined using the union keyword. Names that are defined using the class keyword can be declared using the struct keyword (and vice versa). Therefore, the following code samples are legal:

// elaborated_type_specifiers1.cpp
struct A;   // Forward declaration of A.

class A   // Define A.
{
public:
   int i;
};

int main()
{
}
// elaborated_type_specifiers2.cpp
class A;   // Forward declaration of A

struct A
{
private:
    int i;
};

int main()
{
}
// elaborated_type_specifiers3.cpp
union A;   // Forward declaration of A

union A
{
   int  i;
   char ch[2];
};

int main()
{
}

The following examples, however, are illegal:

// elaborated_type_specifiers4.cpp
union A;   // Forward declaration of A.

struct A
{   // C2011
   int i;
};
// elaborated_type_specifiers5.cpp
union A;   // Forward declaration of A.

class A
{   // C2011
public:
   int i;
};
// elaborated_type_specifiers6.cpp
struct A;   // Forward declaration of A.

union A
{   // C2011
   int  i;
   char ch[2];
};

Community Additions

Show:
© 2014 Microsoft