Virtual Inheritance

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • news-east

    #1

    Virtual Inheritance

    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 **
    ----------------------------------------------------------
    Best Usenet Service Providers 2026 ranked by Newsgroup Access Newsservers, Usenet Search, Features & Free Trial. Add VPN for privacy.

  • Victor Bazarov

    #2
    Re: Virtual Inheritance

    "news-east" <Aidend@None> wrote...[color=blue]
    > 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* ?[/color]

    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


    Comment

    Working...