#include "stdafx.h"
#include <iostream>
using namespace std;
class CA
{
public:
virtual void showa()
{
cout<<"CA1"<<endl;
}
virtual void showd()
{
cout<<"CA2"<<endl;
}
};
class CB
{
public:
virtual void showb()
{
cout<<"CB"<<endl;
}
};
class CC
{
public:
virtual void showc()
{
cout<<"CC"<<endl;
}
};
class CD : public CA , public CB , public CC
{
public:
void showc()
{
cout<<"CD"<<endl;
}
};
typedef void (*fun)();
int _tmain(int argc, _TCHAR* argv[])
{
CD* a = new CD();
int* pVT = (int*)*((int*)(a));//指向CA的虚函数表入口地址
fun * fu = (fun*)(pVT+1);//调用CB::showb()
(*fu)();
pVT = (int*)*((int*)(a)+1);//指向CB的虚函数表入口地址
fun * fu = (fun*)(pVT);//调用CA::showd()
getchar();
return 0;
}