Inheritance Keywords

C++ Specific —>

class [__single_inheritance] class-name;

class [__multiple_inheritance] class-name;

class [__virtual_inheritance] class-name;

class-name

The name of the class being declared.

If you need to declare a pointer to a member of a class prior to defining the class, you can specify the inheritance used in the class declaration using the __single_inheritance, __multiple_inheritance, or __virtual_inheritance keywords described here, thus allowing control of the code generated on a per-class basis. Or you can use either the /vmg compiler option or the related pointers_to_members pragma.

Note   If you always declare a pointer to a member of a class after defining the class, you don't need to use any of these options.

Declaring a pointer to a member of a class prior to the class definition affects the size and speed of the resulting executable file. The number of bytes required to represent a pointer to a member of a class and the code required to interpret the representation may depend on whether the class is defined with no, single, multiple, or virtual inheritance.

In general, the more complex the inheritance used by a class, the greater the number of bytes required to represent a pointer to a member of the class and the larger the code required to interpret the pointer.

As shown in this example,

class __single_inheritance S;
int S::*p;

regardless of command-line options or pragmas, pointers to members of class S will use the smallest possible representation.

Note   The same forward declaration of a class pointer-to-member representation should occur in every translation unit that declares pointers to members of that class, and the declaration should occur before the pointers to members are declared.

END C++ Specific