填空题将x+y中的+运算符用友元函数重载,应写为 。
填空题输出带引号的字符串“hello world!”的语句是
________
。
填空题下面程序的输出结果是______。
#include <iostream>
#include <math>
using namespace std;
class point
{
private:
double x;
double y;
public:
point(double a,double b)
{
x=a,
y=b;
friend double distance(point a,point b);
};
double distance(point a,point b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b,y)*(a.y-b.y));
}
int main()
{
point p1(1,2);
point p2(5,2);
cout<<distance(p1,p2)<<endl;
return 0;
}
填空题写出下列程序的运行结果{{U}} 【13】 {{/U}}。
#include <iostream.h>.
#include <fstream.h>
#include <stdlib.h>
void main()
{
fstream outfile, infile;
outfile.open("data.clat", ios:: out);
if(!outfile)
{
cout<<"Can't open the file."<<end1;
abort();
}
outfile<<" 1234567890"<<end1;
outfile<<"aaaaaaaaa"<<end1;
outfile<<"**********"<<end1;
outfile.close();
infile.open("data. dat ", ios:: in);
if(!infile)
{
cout<<"Can't open the file."<<end1;
abort();
}
char line[80];
int I=0;
while(!infile. eof())
{
I++;
infile.getline(line, sizeof(line));
cout<<I<<":"<<line<<end1;
}
infile.close();
}
填空题有如下程序: #include<iostream> using namespaee std;c lass Animal public: virtual char*getType( )constreturn"Animal"; virtual char*getVoice( )constreturn"Voice"; ; class Dog:public Animal public: char*getType( )constreturn"Dog"; char*getVoice( )eonstreturn"Woof"; ; void type(AnimalA) cout<<a.getType( ); void speak(Animal A) eout<<a.getVoice( ); int main( ) Dog d;type(D) ;cout<<"speak";speak(D) ;cout return 0; 程序的输出结果是______。
填空题下列程序的输出结果是______。 #include<stdio.h> int fun(int x) static int t=0; return(t+=x); void main() int s,i; for(i=1;i<=5;i++)s=fun(i); printf("%d/n",s);
填空题有如下的函数定义:
int Xfun(int x){
int y=x;
{int x=10;y+=x;}
return x+y;
}
通过表达式Xfun(5)调用该函数,则得到的返回值为______。
填空题下列程序的输出结果是 【10】 。 #include <iostream> using namespace std; int main() int data=1; int data+=5; r+=5; cout<<data<<end 1; return 0;
填空题软件测试的常用方法通常可分为白盒测试和 【5】 。前者是根据程序的内部逻辑来设计测试用例,后者是根据软件的规格说明来设计测试用例。
填空题设有定义语句:int a=12;,则表达式a*=2+3的运算结果是 【6】 。
填空题在下面程序横线处填上适当内容,以使该程序执行结果为:
The pair is(21,55)
The pair is(21.7,85.4)
#include <iostream>
using namespace std;
template<class T>
class pair {
public:
T x,y;
void show(){
cout<<"The pair is("<<x <<","<< y<<")"<<endl;
}
};
int main() {
______;
c1. show();
______
c2. show();
return 0;
}
填空题用class定义的类中的数据和成员函数默认类型为______。
填空题将x+y * z中的“+”用成员函数重载," * "用友元函数重载应写为
______
。
填空题以下程序的输出结果是{{U}} 【8】 {{/U}}。
#include<iostream.h>
void fun()
{ static int a=0;
a+=2;
cout << a < < " ";}
void main()
{ int cc;
for(cc=1;cc<4;CC++)
fun();
cout<<endl;}
填空题以下程序输出的结果是______。 #include <iostream.h> void main() int a=5,b=4,c=3,d; d=(a>b>c); cout<d;
填空题以下程序的运行结果是 【12】 。 #include<iostream.h> func(int a,int b) statlC int m=0,i=2; i+=m+1; m=i+a+b; return m; void main() int k=4,m=1,p; p=func(k,m);cout<<p<<”,”; p=func(k,m);cout<<p<<endl;
填空题根据注释内容在空白处填写适当内容。
class Location
{
private:
int X,Y;
public:
void init(int init X,int init Y);
int GetX( );
int GetY( )
};
void Location:: init(int initX,int initY)
{
X = initX
Y=initY;
}
int Location: :GetX( )
{
reutrn X
}
int Location: :GetY( )
{
reutrn Y;
}
# inelude<iostream. h>
void main( )
{
Location A1;
A1. init (20, 90)
{{U}} 【13】 {{/U}} //定义一个指向A1的引用rA1
cout<<rA1. GetX()<<": "<<rA1. GetY()<<end1;
}
填空题根据输出结果填空完成下面程序。 #include<iostream.h> class Test private: static int val; int a; public: static int func( ); void sfunc(Test ; ______//初始化静态变量val int Test::func( ) return val++; void Test::sfunc(Test cout<<"Result3="<<r.a; void main( ) cout<<"Resultl="<<Test::func( )<<endl; Test A; cout<<"Result2="<<A.fune( )<<endl; A. sfunc(A); 输出结果为: Result1=201 Result2=202 Result3=125
填空题求1~100的和,可写成for(s=0,i=1;______;i++) s+=1的形式。
填空题阅读下面程序: #include <iostream.h> int fun2(int m) if(m%3==0) return 1; else return 0; void fun1(int m,int for(i=1;i<m;i++) if(fun2(i)) s=s*i; void main() int n=9,s=2; fun1(n,s); cout<<s<<endl; 该程序的运行结果是______。
