i6lan 分享题目的网站
试一试站内搜索 题目类型:问答题

在ON-call表生效后,原则
饮酒后或者醉酒驾驶机动车发生重
在党内搞团团伙伙、结党营私、拉
党员领导干部不重视家风建设,对
大亚湾核电基地突发事件牵头负责

给出下面程序输出结果。


#include <iostream.h>

class Test

{int x,y;

public:

Test(int i,int j=0)

{x=i;y=j;}

int get(int i,int j)

{return i+j;}

};

void main()

{Test t1(2),t2(4,6);

int (Test::*p)(int,int=10);

p=Test::get;

cout<<(t1.*p)(5)<<endl;

Test *p1=&t2;

cout<<(p1->*p)(7,20)<<endl;

}


答案:15  27

[解析]指向类成员函数的指针的使用,*p指向Test类中有两个参数的函数的一个指针。P=Test::get.这样p就和get发生了联系。(t1.*p)(5)等价于调用一个参数的get函数。

上一题 下一题

CopyRight©i6lan.com 关于本站
蜀ICP备2021017061号-1

川公网安备 51010402001278号