Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - virtual_base_classes _ http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
                           Virtual_Base_Classes                       _
   Virtual  base classes avoid possible problems caused by the same  base
   class  being  multiply included in a derived class by being  itself  a
   base class to one or more of the parent classes of the derived class.

   If  a class inherits the same base class from two other classes,  then
   the  class  constructor for this base class is called twice,  and  the
   derived  class contains two instances of this class, each with a  full
   sets  of members. If a shared member function is used, the  programmer
   must explicitly state through the use of the class resolution operator
   whether  the  version is to be inherited through one or other  of  the
   immediate base classes to be invoked.

   Thus  if class A is inherited into class B and also into class  C  and
   these classes in turn are inherited into class D, class D will contain
   two  instances  of class A. If a member function of class A is  to  be
   used within a member function of class D, it will have to be  accessed
   using  either  B::  or  C:: to indicate  which  of  the  two  possible
   instances should be used.

   In some cases these multiply inherited instances may be required,  but
   usually  they will not. The definition of the offending base class  as
   virtual  means that only a single copy of the class will  be  included
   into  a  derived  class  no matter how many times  it  occurs  in  the
   inheritance tree.


Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson