question about virtual apstract class.

hi,
let's suppose you have one apstract class named class A:

1
2
3
class A {

};


ve also have two classes B and C which will inherit class A:
1
2
3
4
5
6
7
class B : public virtual A {

};

class C : public A {

};

as you see class B inherit class A as virtual and class C inherits class A as "non-virtual"

now we have some class D which will inherit class B and C:

1
2
3
class D : public B, public C {

};


OK,
now my qustion is: will class D inherit in THIS case class A two times or only once??

I know it will inherit it only onece if B and C would both inherit A as virtual, on another side I also know that D will interit class A two times if B and C both inherit class A as "non-virtual"...

so I'm confused what hapens when one(B) inherits A as virtual and another (C) inherits A as "non-virtual".
what will class D have 2xA or 1xA and why?

thanks in advance and your time!
Last edited on
Topic archived. No new replies allowed.