IBM CPP
IBM CPP
In the following example, an object of class D has two distinct subobjects of class L, one through class B1 and
another through class B2. You can use the keyword virtual in front of the base class specifiers in the base lists
of classes B1 and B2 to indicate that only one subobject of type L, shared by class B1 and class B2, exists.
For example:
Using the keyword virtual in this example ensures that an object of class D inherits only one subobject of class
L.
A derived class can have both virtual and nonvirtual base classes. For example:
class V { /* ... */ };
class B1 : virtual public V { /* ... */ };
class B2 : virtual public V { /* ... */ };
class B3 : public V { /* ... */ };
class X : public B1, public B2, public B3 { /* ... */
};
In the above example, class X has two subobjects of class V, one that is shared by classes B1 and B2 and one
through class B3.
Related reference
1 of 2 10/12/10 17:09
Virtual base classes (C++ only) http://publib.boulder.ibm.com/infocenter/cellcomp/...
[ Provide feedback ]
2 of 2 10/12/10 17:09