Inheritance and how to bring the types of interfaces?

Please help me to understand how best to do:
and so, there is a class and its interface IA, which inherits from class B interface IB
class A: public IA, public B
 void a();

class IA 
 virtual a()=0;

class B: public IB
 void b();

class IB 
 virtual b()=0;

At some point the program I get a pointer to IA*,
but I need to call methods from B,
but the interface is not inherited IA from IB (if inherited, it would be a mistake "... is ambiguous" ),
and you can only use IA or IB without the ability to access A or B.

So, how do I best create these two classes and their interfaces (A, IA, B, IB) that it was possible to do so:
IA * a = ....;
a->b(); ???
July 2nd 19 at 17:32
2 answers
July 2nd 19 at 17:34
Yeah, crutches Pattern adapter
Bad example
#include <iostream>
using std::cout;
using std::endl;

struct IB {
 virtual void b() = 0;

struct B : IB {
 void b() override { cout << "B::b" << endl; }

struct IA {
 virtual void a() = 0;

struct A : IA, B {
 void a() override { cout << "A::a" << endl; }

struct IAB : IA, IB {
 IAB(IA *ia IB *ib) : ia(ia), ib(ib) {}
 void a() override { ia->a(); }
 void b() override { ib->b(); }
 IA *ia;
 IB *ib;

int main() {
 A A;
 IAB iab(&a, &a);

Same on ideone
Pichal =( crutches nehochetsya... - darrell commented on July 2nd 19 at 17:37
it is not that crutches, I just don't write in C++ and my solutions should be treated with skepticism. - charity84 commented on July 2nd 19 at 17:40
: Yes, without the crutches turned out the decision to invent, unsubscribe below. But thank You for the sample adapter =) - darrell commented on July 2nd 19 at 17:43
July 2nd 19 at 17:36
Ya woodpecker. The decision simple - virtual inheritance!
Uh, why is virtual inheritance?
IA *a = ...;
if ( IB *b = dynamic_cast< IB* >( a ) )
b->b(); - darrell commented on July 2nd 19 at 17:39
: there is a mistake IA not inherit from Ib - charity84 commented on July 2nd 19 at 17:42
: if in fact a is an instance of A class, i.e. inherited including from IB, then there will be no error. If it is not, then the method call of a class IB incorrect in any case. - darrell commented on July 2nd 19 at 17:45

Find more questions by tags C++Patterns of designing