更多"下列程序编译错误,是由于划线处缺少某个语句,该语句是______。 "的相关试题:
[填空题]下列程序编译错误,是由于划线处缺少某个语句,该语句是 【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);
}
[填空题]下列程序编译错误,是由于划线处缺少某个语句,该语句是 【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);
[填空题]下列程序编译错误,是由于划线处缺少某个语句,该语句是______。
#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.numl+obj2.num2);
}
void main(void)
{
A objl(4);
B obj,obj2(5);
cout<<"obj1+obj2:"<<obj.my_math(obj1,obj2);
}
[填空题]下列程序中需要清理动态分配的数组,划线处应有的语句是 【13】 。
#include<iostream, h>
class person
{
int age, tall;
public:
person( ) { age= 0; tall= 40; cout<<"A baby is born. "<<end1;}
person(int i) {age=i, tall=40, cout<<"A old person. "<<end1;}
person(int i, int i) { age = i; tall = j; cout <<" a old person with tall. "<<
end1;}
~person( ) {cout<<" person dead. "<<end 1;}
void show( )
{
cout<<"age= "<<age<<" ,tall= "<<tall<<end1;
}
};
void main( )
{
person * ptr;
ptr = new person[3];
ptr[0]=person ( )
ptr[1]=person(18);
ptr[2]=person(20,120);
for(int i=0;i<3; i++)
ptr[i]. show( );
______
}
[填空题]下列类的构造函数不能通过编译,正确的构造函数应该是______。
#include<iostream.h>
class Sample
{
public:
int n;
const int con;
Sample(int m) {con=m+1;n=m;}
void disp( ) {cout<<"normal:n="<<n<<endl;}
void disp( )const {cout<<"static:n="<<n<<endl;}
};
void main( )
{
const Sample a (12);
Sample b (13);
a.disp( );
b.isp( );
cout<<a.n<<","<<b.con<<endl;
}
[填空题]以下程序设计功能是:将结构体变量time 中的内容写到文件中。
#include <iostream>
using namespace std;
struct date
int year;
int month;
int day;
int main ( )
date time = 2005, 1, 1 ;
ofstream outdate;
outdate.open( "d://date.txt", ios :: binary );
outdate.write(____________, sizeof( tt ) );
outdate.close( );
return 0;
则程序中空白处应该填入的语句为 【15】 。
[填空题]已知下列程序的输出结果是42,请将横线处缺失的部分补充完整。
#include<iostream>
using namespace std;
class Foo{
int value;
public:
Foo( ):value(0){}
void setValue(int value)
{______=value; ∥给Foo的数据成员value赋值}
void print( ){cout<<value;p}
};
int main( )
{
Foo f;
gf.setValue(42);
f.print( );
return 0;
}
[填空题]已知下列程序的输出结果是42,请将下画线处缺失的部分补充完整。
#include <iostream>
using namespace std;
class Foo
int value;
public:
Foo( ):value(0)
void setValue(int value)
______=value;//给Foo的数据成员value赋值
void print( )eout<<value;
;
int main( )
Foo f;
f.setValue(42);
f.print( );
return 0;
[填空题]设文件temp.txt 已存在,则以下的打印结果是 【15】
#include <iostream>
#include <fstream>
using namespace std;
int main( )
{
ofstream outf ("temp.txt",ios base: :trunC) ;
outf<<"How you doing";
outf.close( );
ifstream inf("temp.txt");
char str[20];
inf>>str;
inf.close( );
cout<<str;
return 0;
}
[填空题]下列程序编译错误,因为add函数返回值是一个引用,故对return后返回值的要求是 。
#include<iostream. h>
int& add(int x, int y)
return x+y;
void main( )
int i=3,j=19;
cout<<(add(i,j)+ =20)<<end1;
[填空题]下列程序编译错误,因为add函数返回值是一个引用,故对return后返回值的要求是 【10】 。
#include<iostream. h>
int& add(int x, int y)
{
return x+y;
}
void main( )
int i=3,j=19;
cout<<(add(i,j)+ =20)<<end1;
}
[填空题]下列程序编译错误,因为add函数返回值是一个引用,故对return返回值的要求是______。
#include<iostream.h>
int& add(int x,int y)
return x+y;
void main( ) int i=3,j=19;
cout<<(add(i,j)+=20)<<endl;
[填空题]程序文件的编译错误分为语法错误和 【4】 两类。