Export (0) Print
Expand All

Defining Class Types

Updated: October 2008

Class types are defined using class specifiers. Class types can be declared using elaborated type specifiers as shown in Type Specifiers. The class specifier consists of:

  • The class, struct or union keyword.

  • The class heading includes the class name and the applicable template heading.

  • Optionally, a colon and the base list which identifies the base classes that the class being defined inherits from.

  • Braces ({}) containing the class member declarations.

Class names are introduced as identifiers immediately after the compiler processes them (before entry into the class body); they can be used to declare class members. This allows declaration of self-referential data structures, such as the following:

// defining_class_types.cpp
// compile with: /c
class Tree
{
public:
   void *Data;
   Tree *Left;
   Tree *Right;
};

Date

History

Reason

October 2008

Deleted repeated text.

Customer feedback.

Community Additions

ADD
Show:
© 2014 Microsoft