#include _________________using namespace std; class base { publ

作者:高老师 浏览 1

完成程序题:请按空格顺序填写答案。

完成下面程序中的show函数的定义,使其运行结果如下:

In base
In derived


#include _________________
using namespace std;
class base
{
public :
virtual void print( )
{
cout << "In base" << endl;
}
};
class derived: public base
{
public :
void print( ) { cout << "In derived" << endl; }
};
void show(base * pb,void (base:: * pf) ( ) )
{
_________________
}
void main( )
{
base b;
derived d ;
show ( &b, base::print);
show ( &d, base::print);
}


【正确答案】:

第1空:<IOSTREAM>
第2空:(PB->*PF)( );


【题目解析】:

常用的头文件有以下一些。 

(1)标准输入输出流:,当程序中用到cin和cout时,需要在程序中包含头文件。 

(2)标准文件流:
(3)标准字符串处理函数:
(4)标准数学函数:

 .*和->*都是成员指针访问运算符。


📱 扫码体验刷题小程序

微信小程序二维码

扫一扫使用我们的微信小程序

热门题目

已复制到剪贴板