virtual base class overhead

T

Thomas Maier-Komor

Hi,

let's assume there is an abstract base class (ABC), which is
inheritet virtually by two classes (A,B). A and B themselves
are inheritet by another class (C). What kind of overhead
should I expect compared to a class X, which implements
the virtual functions of the base classes directly without
an additional inheritance layer? Is it compiler dependent or
are there any fundamental tradeoffs with the implementation
of class C?

Thanks,

Tom


struct ABC
{
virtual int foo() = 0;
virtual float bar() = 0;
};

struct A : public virtual ABC
{
int foo()
{ return 0; }
};

struct B : public virtual ABC
{
float bar()
{ return 0; }
};

struct C : public A, public B
{

};

struct X : public ABC
{
int foo()
{ return 0; }
float bar()
{ return 0; }
};
 

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

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top