Hi,

I have some questions about c++ inheritance and performance:

1) How does single inheritance affect performance? Consider the following example:

Code:
class Base
{
public:
  virtual void f1();
  virtual void f2();
  ...
}

class Derived
{
  public virtual void f1();
  ...
}
Class Derived overrides the implementation of f1() and inherits the implementation of f2() from Base. How do calls to f1() and f2() perform on an object of class Derived? That is, if the functions are called millions of times (in a for loop, for instance), is the overhead caused by the function call identical for f1() and f2()? And what about calling f1() and f2() on an object of type Base (compared to calling them on an object of type Derived)?

Is maybe somebody aware of some good (online) articles that describe how single inheritance affects performance?

2) I've found some articles that state that multiple inheritance may perform badly, particularly if virtual base classes are involved. What about multiple inheritance without virtual base classes? For example, I could define a pure virtual class only consisting of method signatures (like an interface in java). Then a class could be derived from some base class and this interface (there exist many examples for that in java):

Code:
class Base
{
public:
  virtual void f1();
  virtual void f2();
  ...
}


class Interface
{
public:
  virtual void i1() = 0;
  ...
}


class Derived: public Base, public Interface
{
public:
  virtual void i1();
  virtual void f1();
  ...
}
How do calls to the functions i1, f1 and f2 perform compared to each other when called on an object of type Derived? And how do calls to f1 and f2 perform when calling them on an object of type Base compared to calling them on an object of type Derived?

Are there any reasons (not only performance) that argue against this use of multiple inheritance?

Thanks,

Michael