yinweishifeicha 发表于 2016-1-17 01:04:01

一道C艹的题!!大神们能不能帮助解答!!!期末考试啦!!!

#include <iostream.h>
classA
{
public:
virtual void f()
{ cout<<"A::f()called\n"; }
};
class B:public A
{
public:
void f()
{ cout<<"B::f()called\n"; }
};
void main()
{
B b;
A &r=b;
void (A:: *pf)()=A::f;
(r.*pf)();
}

为什么答案是B::f() called啊?????????
void (A:: *pf)()=A::f;
这句并没能看懂{:10_247:}
求解析

黑龍 发表于 2016-1-24 23:02:21

因为 a &=b

黑龍 发表于 2016-1-24 23:02:36

a &r=b
页: [1]
查看完整版本: 一道C艹的题!!大神们能不能帮助解答!!!期末考试啦!!!