Virtual base class is a base class acts as an indirect base
for more than one without duplication of its data members.
A single copy of its data members is shared by all the base
classes that use it as a virtual base.
For example:
A
/ \
B C
\ /
D
class A { /* ... */ }; // indirect base class
class B : virtual public A { /* ... */ };
class C : virtual public A { /* ... */ };
class D : public B, public C { /* ... */ }; // valid
Using the keyword virtual in this example ensures that an
object of class D inherits only one subobject of class A.
Thursday, June 17, 2010
Virtual Base Class How To?
Labels:
C C++
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.