在答题纸上填上缺少的部分。源程序如下:
#include ﹤iostream﹥
#include ﹤fstream﹥
using namespace std;
void main( )
{
_________ myf("aB.txt"); //定义输出流文件,并初始化
_________﹤﹤"This ia a TXT file"; //向文件输入字符串
myf.close( );
}
在字符串类string中实现一个判断函数,该函数功能是统计某一字符串类对象(仅有单词和空格组成)有多少个单词,同时保存所有单词在字符串中的起始地址(设该字符串不超过100个单词)
#include ﹤string﹥
class str{
string s; int n, a[100], j, l;
public: str(string &a){s=a; n=0; j=0; l=0;}
....test(....);
int *geta( ){return a;}
};
请写出test函数的过程(如果需要形式参数,请给出形参类型和数量,以及返回值类型)
给出下面程序的输出结果
class base
private:
int x;
public:
void setx(int a){x=a;}
int getx( ){return x;}
base a, b;
a.setx(89);
b=a;
cout﹤﹤a.getx( )﹤﹤endl;
cout﹤﹤b.getx( )﹤﹤endl;
下面程序的运行结果如下: 20,22 60,22
const int a;
static const int b;
base(int);
void Show( );
_________=22;
_________ : a(i){ } //初始化
void base:: Show( )
{ cout﹤﹤a﹤﹤","﹤﹤b﹤﹤endl; }
base a1(20), a2(60);
a1.Show( );
a2.Show( );
int *p;
base a;
a.setx(15);
p=new int(a.getx( ));
cout﹤﹤*p;
下面程序给出了一个从普通的基类派生出一个模板类的方法,在答题纸上填上缺少的部分。
class Base
public:
Base(int a){x=a;}
int Getx( ){return x;
void showb( ){cout﹤﹤x﹤﹤endl; private: int x;
template﹤class T﹥
class derived: public Base
derived(T a, int b): _________
{ y=a; }
T Gety( ){ return y; }
void showd( ){cout﹤﹤y﹤﹤" "﹤﹤Gets( )﹤﹤endl;
_________
{ Base A(458);
A. showb( );
derived ﹤char *﹥B("It is",1357);
B.showd( );
在下面程序中的答题纸上填上适当的程序,使程序的输出结果如下: 67,90 源程序如下:
pnvate:
int x,y;
priblic:
void initxy(int a,int b){x=a;y=b;}
void show(base *p);
inline void base::show( _________ )
cout﹤﹤p-﹥x﹤﹤" "﹤﹤p-﹥y﹤﹤endl;
void print(base *p)
p-﹥show(p);
a.initxy(67,90);
print( _________ );
int a, b;
base(int x, int y){a=x; b=y;}
void show( _________ )
cout﹤﹤p.a﹤﹤″,″﹤﹤p.b﹤﹤endl;
}_________
base b(78,87);
b.show(b);
#include ﹤iostream.h﹥
class f{
private: int x,y;
public: f1(int a, int b){x=a; y=b;}
void print( ){cout﹤﹤x--﹤﹤y﹤﹤endl;
main( ){
f a;
float x=1.0, y=2.0;
a.f1(x,y);
a.print( );
class test{
private: int x;
public: test(int a){x=a;}
void set(int a){x=a;}
void get( ){cout﹤﹤x﹤﹤endl;
class test1: public test{
public: test1(int a){x=a;}
void get( ){cout﹤﹤′ ′﹤﹤endl;
热门试卷
经济师初级(经济基础知识)模拟试卷5
经济师初级经济基础知识(商品经济的基
经济师(初级)工商管理专业知识与实务
初级经济师试题及答案3(公路运输)
经济师初级人力资源管理专业知识与实务
初级经济师《工商专业》全真模拟试卷(
初级经济师《经济基础知识》考前突破试
订单号:
遇到问题请联系在线客服