Defining Class Types
Class types are defined using class-specifiers. Class types can be declared using elaborated-type-specifiers as shown in Type Specifiers in Chapter 6.
Syntax
- class-specifier :
class-head { member-listopt } - class-head :
class-key imodelopt identifieropt base-specopt
class-key imodelopt class-nameopt base-specopt - class-key :
class
struct
union - imodel :
__declspec
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:
class Tree { public: void *Data; Tree *Left; Tree *Right; };