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

能与空气中的氧或其它氧化剂起化
大亚湾核电站、岭澳核电站四台机
标准及机构代码:ECMA的英文
世界上航空航天最重要的金属是什
加气站、加油加气合建站设置的可

给出下面程序输出结果。


#include <iostream.h>

class test

{int x;

public:

test(int i=0):x(i){}

virtual void fun1()

{cout << "test::x"<<x<<endl;}

};

class ft:public test

{int y;

public:

void fun1(){cout <<"ft::y="<<y<<endl;}

ft(int i=2):test(i),y(i){}

};

void main()

{ ft ft1(3);

void (test::*p)();

p=test::fun1;

(ft1.*p)();

}


答案:ft::y=3

[解析]指向函数的指针的使用,p指向fun1函数,(ft1.*p)实际就是调用ft1对象的fun1()函数。

上一题 下一题

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

川公网安备 51010402001278号