填空题设在主函数中有以下定义和函数调用语句,且fun()函数为void类型,请写出fun()函数的首部{{U}} 【7】 {{/U}}。
int main()
{
double s[10][22];
int n;
...
fun(s);
...
return0;
}
填空题以下程序执行后输出的结果是{{U}} 【15】 {{/U}}。
#include<iostream>
#include<fstream>
using namespace std;
int main(){
ofstream ofile("D://temp.txt");
if(!ofile){
cout<<"temp.txt cannot open"<<endl;
return 0;
}
ofile<<"This is a book" <<" " <<54321<<endl;
ofile.close();
ifstream ifile("D://temp.txt");
if(!ifile){
cout<<"temp.txt cannot open" <<endl;
return 0;
}
charstr[40];
ifile >> str;
ifile.close();
cout<<Str<<endl;
return 1;
}
填空题下列程序的输出结果是{{U}} 【15】 {{/U}}。
#include <iostream>
using namespace std;
class A {
int a;
public:
A():a(9){}
virtual void print() const { cout<<a;};
};
class B: public A {
char b;
public:
B( ){b='S';}
void print() const {cout<<b;}
};
void show(A }
int main()
{ Ad1,*p;
B d2;
p=
d1.print();
d2.print0;
p->print();
show(d1);
show(d2);
return 0;}
填空题以下程序的执行结果是_____。
#include<iostream.h>
#include<iomanip.h>
voidmain()
{
cout.fill("*");
cout.width(10);
cout<<setiosflags(ios::left)<<"123.45"<<endl;
cout.width(8);
cout<<"123.45"<<endl:
cout.width(4);
cout<<"123.45"<<endl;
}
填空题若Xcs是一个类,该类中具有一个函数体为空的不带参数的构造函数,此构造函数的类外定义为___【10】___。
填空题在C++中,打开一个文件,就是将这个文件与一个{{U}} 【10】 {{/U}}建立关联,关闭一个文件,就是取消这种关联。
填空题若有定义“int k;”,下列程序段的输出结果是______。
for(k=2;k<6;k++,k++)printf("##%d",k);
填空题执行以下程序后,输出“#”号的个数是 【14】 。 #include<iostream.h> main() int i,j; for(i=1;i<5;i++) for(j=2;j<=i;j++) cout<'#';
填空题一个类中有{{U}} 【10】 {{/U}}个构造函数。
填空题用来派生新类的类称为______,而派生出的新类称为它的子类或派生类。
填空题请将下列栈类Stack补充完整。 class Stack private: int pList[100]; //int数组,用于存储占的元素 int top; //栈顶元素(数组下标) public: Stack( ):top(0) void Push(const intitem); //新元素item压入栈 int Pop(void); //将栈顶元素弹出栈 ; void Stack::Push(const intitem) if(top==99) exit(1); //如果栈满,则程序终止 top++; //栈顶指针增1 ______; int Stack::Pop( ) if(top<0) exit(1); //如果栈空,则程序终止 return Plist[top--];
填空题与成员访问表达式p→name 等价的表达式是 【14】 。
填空题数据的逻辑结构在计算机存储空间中的存放形式称为数据的{{U}} {{U}} {{/U}} {{/U}}。
填空题下列程序编译错误,是由于划线处缺少某个语句,该语句是 【15】 。 #include <iostream. h> class A ______ private: int numl; public: A():numl(0) A(int i):numl(i) ; class B private: int num2 public: B():num2(0) B(int i):num2(i) int my_math(A obj1,B obj2); ; int B::my_math(A obj1,B obj2) return (obj1.num1+obj2.num2); void main(void) A obj1 (4) B obj,obi2(5); cout <<"obj1+obj2:"<<obj.my_math(obj1,obj2);
填空题下列程序的输出结果是 【10】 。 #include <iostream> using namespace std; void fun(int int main() int num= 500; fun(num); cout<<num<<end1; return 0;
填空题在下面函数的横线处填上适当的内容使该函数能够利用递归方法求解字符串str的长度(不得使用系统提供的字符串处理函数)。 int GetLen(char *str if ( 【6】 ) return 【17】 ; else return 1+GetLen (str+1);
填空题以下程序的输出结果是{{U}} 【14】 {{/U}}。
#include<iostream.h>
void main( )
{ int a=0;
a+ =(a=8);
cout < < a;
}
填空题动态联编中直到______时才能确定调用哪个函数;而静态联编则是在______时进行的。
填空题下面是复数类complex的定义,其中重载的运算符“+”的功能是返回一个新的复数对象,其实部等于两个操作对象实部之和,虚部等于两个操作对象虚部之和;请补充完整。 class complex double real; //实 double imag; //虚部 public: complex( double r, double i):real(r),imag(i) complex operator + (complex a) return complex(______); ;
填空题设a,b和c都是整型,且值都是5,执行a+=b+c++;则a,b和c的结果分别是 [6] 。