64,648
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
class A
{
public:
virtual void f(){cout<<"A:f() is called."<<endl;}
};
class B:public A
{
public:
virtual void f(){cout<<"B:f() is called."<<endl;}
};
int main()
{
B b;
A &x = b;
void (A::*pf)()=&A::f;
(x.*pf)();
cout<<endl<<endl;
x.f();
return 0;
}