-
class Base{
-
private:
-
virtual void f() { cout<<\"Base::f\"<<endl; }
-
virtual void g() { cout<<\"Base::g\"<<endl; }
-
};
-
-
class DeriveChild:public Base{
-
-
};
-
typedef void (*Fun)(void);
-
void main()
-
{
-
DeriveChild d;
-
Fun pFun=(Fun)*((int*)*(int*)(int*)(&d)+0);
-
pFun();
-
pFun=(Fun)*((int*)*(int*)(int*)(&d)+1);
-
pFun();
-
}
-
class B
-
{
-
public:
-
virtual void fun()
-
{
-
cout<<\"Base fun called\"<<endl;
-
}
-
};
-
-
class D:public B
-
{
-
private:
-
virtual void fun()
-
{
-
cout<<\"driver fun called\"<<endl;
-
}
-
};
-
void main()
-
{
-
B *p=new D();
-
p->fun();
-
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29012686/viewspace-1131003/
,如需转载,请注明出处,否则将追究法律责任。