Code: Select all
class WIFI
{
public :
WIFI()
{
}
void foo()
{
std::cout << "WIFI";
}
};
class LTE
{
public :
LTE()
{
}
void foo()
{
std::cout << "LTE";
}
};
class XSystem : public LTE, public WIFI
{
public :
XSystem()
{
}
void foo()
{
std::cout << "XSystem";
}
};
int _tmain(int argc, _TCHAR* argv[])
{
LTE obj;
((XSystem*)(&obj))->foo();
int i;
std::cin >> i;
return 0;
}
The above prints XSystem, however, if you add a virtual keyword at parent class LTE.foo(), then it will print LTE.