Extending interfaces using inheritance
<pre><code>class IA
{
public:
    virtual void a() = 0;
};

class A: public IA
{
public:
    virtual void a()
    {
    }
};

class IB
{
public:
    virtual void b() = 0;
};

class B: public IB, public A
{
public:
    virtual void b()
    {
    }
};

void f(IA* p)
{

}

int main() 
{
    B b = B();
    IB* p = &amp;b;
    f(p);
}
</code></pre>

<p>Is this the correct way to implement interfaces with inheritance in C++? If so, how do I get the line <code>f(p);</code> in my code to compile? Basically, I would like if <code>IB</code> could inherit from <code>IA</code> but this will cause problems for B.</p>

<p><strong>UPDATE</strong></p>

<p>What I want is for <code>IB</code> to include <code>IA</code>'s interface, as follows. However this code wont compile since <code>IA::a()</code> and <code>A::a()</code> conflict with each other. What should I do?</p>

<pre><code>class IA
{
public:
    virtual void a() = 0;
};

class A: public IA
{
public:
    virtual void a()
    {
    }
};

class IB : public IA
{
public:
    virtual void b() = 0;
};

class B: public IB, public A
{
public:
    virtual void b()
    {
    }
};
</code></pre>

<p><strong>UPDATE 2</strong></p>

<p>This compiles, does it look correct? Do I need all these virtuals</p>

<pre><code>class IA
{
public:
    virtual void a() = 0;
};

class A: virtual public IA
{
public:
    virtual void a()
    {
    }
};

class IB: virtual public IA
{
public:
    virtual void b() = 0;
};

class B: virtual public IB, public A
{
public:
    virtual void b()
    {
    }
};
</code></pre>
