Code:
#include <iostream>
using namespace std;
class foo{
public:
virtual void Sing(){cout << "Foo lalala" << endl;}
};
class bar{
public:
virtual void Sing(){cout << "Bar lalala" << endl;}
};
class foobar: public foo,public bar{
public:
/*Can do what's below...but then why inherit?!..*/
// void Sing(){foo::Sing();bar::Sing();}
};
int main(void) {
foobar fb;
foo* ptrfoo = &fb;
bar* ptrbar = &fb;
// fb.Sing(); //Will cause the ambiguity error!!
fb.foo::Sing();
fb.bar::Sing();
ptrfoo->Sing();
ptrbar->Sing();
return 0;
}
I dont use much MI...but here's a few ideas...
You can implement a Sing() func in the derived class to call the other functions through the scope operator..not great unless you wish to call both....
You can also call the member function from an instance by specifying the base class
Also you can do it by calling from a casting up with a base pointer....