I have a class C
that inherits both from Ai
and B
. A
and B
are unrelated. This is all best explained with the code below. In main()
, I have a variable a
defined as std::unique_ptr<A>
, but initialized with C
. I cannot change this definition.
My question is, given a
defined like this, how can I call functions defined in B
or C
or Ai
correctly?
#include <memory>
class A
{
public:
void fun_a() {}
};
class B
{
public:
void fun_b() {}
};
class Ai : public A
{
public:
void fun_ai() {}
};
class C: public Ai, public B
{
public:
void fun_c() {}
};
int main()
{
// I cannot change the following definition:
std::unique_ptr<A> a = std::make_unique<C>();
a->fun_a();
//a->fun_b(); // How ?
//a->fun_c(); // How ?
//a->fun_ai(); // How ?
return 0;
}