virtual function, inline, diamond?

P

puzzlecracker

I am sure people are familiar with dirty diamond problem solved by
virtual inheritance. look at the code below and tell me how many
instances of the base class (in this case A) does class D receive?


class A
{
:
:

};


class B: virtual public A {

:
:

};
class C: virtual public A {

:
:

};

class D: public B, public C, virtual public A {

:
:

};


====

A small follow up: is inheritance by default public, protected or
private such class A: B{};?

what is the difference between
class A
{
:
:

};


class B: virtual public A {

:
:


};
class D:public B {

:
:

};
OR

class D: virtual public B {

:
:

};

============
Next: can you inline the virtual functions? is the behavior undefined,
nonstandard, etc?
 
P

puzzlecracker

THIS IS NOTa homework problem. LOL!!!! and I am more interested in the
explanation, this is the problem that I came up with myself, blin!
 
A

Alf P. Steinbach

* puzzlecracker:
THIS IS NOTa homework problem. LOL!!!! and I am more interested in the
explanation, this is the problem that I came up with myself, blin!

Idiot.
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top