//继承多个接口,但是有相同的方法
#include <iostream.h>
class IHello
{
public:
virtual void Say() = 0;
};
class IWorld
{
public:
virtual void Say() = 0;
};
class MHello : public IHello
{
public:
void Say(){cout << "Hello ";}
};
class MWorld : public IWorld
{
public:
void Say(){cout << "World" << endl;}
};
class CObject : public MHello, public MWorld
{
};
int main()
{
CObject o;
IHello& ih = o;
IWorld& iw = o;
ih.Say();
iw.Say();
return 0;
}