confusin with virtual inheritance

M

mangesh

considr following code

class V
{ };

class B1 : virtual public V
{};

class B2 : virtual public V
{};

class D : public B1 , public B2
{};

According to my understan B1 , B2 and D will each keep a pointer to V .
is it corect ?
can anyone suggest godd site/book for topic .
 
N

n2xssvv g02gfr12930

mangesh said:
considr following code

class V
{ };

class B1 : virtual public V
{};

class B2 : virtual public V
{};

class D : public B1 , public B2
{};

According to my understan B1 , B2 and D will each keep a pointer to V .
is it corect ?
can anyone suggest godd site/book for topic .
The class D will only have one instance of base class V as shown below

D
/ \
B1 B2
\ /
V

That is both B1 and B2 inherit the same V as part of D. Try not to
confuse pointers with inheritance as this will probably only lead to
greater confusion.

JB
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,241
Latest member
Lisa1997

Latest Threads

Top