Virtual Inheritance

Discussion in 'C++' started by news-east, Nov 28, 2004.

  1. news-east

    news-east Guest

    It's probably a silly question, but if there exists a base class A, and from
    it derives classes B and C, and a further class D multiply-inherits from B
    and C. Let's say B derives virtually from A, and C derives non-virtually.

    What should the compiler behaviour be on instantiation of an object of type
    D* ?



    Posted Via Usenet.com Premium Usenet Newsgroup Services
    ----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
    ----------------------------------------------------------
    http://www.usenet.com
     
    news-east, Nov 28, 2004
    #1
    1. Advertising

  2. "news-east" <Aidend@None> wrote...
    > It's probably a silly question, but if there exists a base class A, and
    > from it derives classes B and C, and a further class D multiply-inherits
    > from B and C. Let's say B derives virtually from A, and C derives
    > non-virtually.
    >
    > What should the compiler behaviour be on instantiation of an object of
    > type D* ?


    An object of type D* is a pointer. Instantiating it does not depend on the
    base classes of D (and their base classes, and so on).

    In case you made a typo and didn't intend to write D*, then there should be
    two objects of class A in a D. One that comes from B and the other from C.
    The Standard specifies so in 10.1/4.

    V
     
    Victor Bazarov, Nov 28, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. maxw_cc
    Replies:
    1
    Views:
    3,160
    Martijn van Steenbergen
    Dec 21, 2003
  2. qazmlp
    Replies:
    19
    Views:
    812
    Daniel T.
    Feb 4, 2004
  3. cppsks
    Replies:
    0
    Views:
    833
    cppsks
    Oct 27, 2004
  4. Ashwin
    Replies:
    2
    Views:
    359
    Pierre Barbier de Reuille
    Aug 1, 2006
  5. Replies:
    1
    Views:
    477
    Alf P. Steinbach
    Mar 14, 2009
Loading...

Share This Page