下列程序不能通过编译,应该在划线部分填写的语句是______。
include<iostream.h>
include<stdlib.h>
double Func(int a,int b,char ch)
{
double x;
switch(ch)
{
case'+':
x=double(a)+b;
break;
case '-':
x=double(a)-b;
break;
case '*':
x=double(a)*b;
break;
case'/':
if(B)x=double(a)/b;
else
exit(1);
break;
default:
exit(1);
}
______
}
void main( )
{
cout<<Func(32,6,'-')<<",";
cout<<Func(32,6, '*')<<",";
cout<<Func(32,6,'/')<<endl;
}
第1题:
下列程序中划线处正确的语句是( )。 # include <iostream> using namespace std; class Base { public: void fun(){cout<<"Base:: fun" <<endl;} }; class Derived:public Base { void fun() { ______ ∥显式调用基类的函数fun() cout<<"D
A.fun();
B.Base.fun();
C.Base::fun();
D.Base- >fun();
第2题:
main函数中发生编译错误的语句是______。
include<iostream.h>
class A
{
public:
int a;
const int b;
A( ):a(10),b(20){}
void fun( )const
{
cout<<"a="<<a<<"\tb="<<b<<endl;
}
};
void main( )
{
A obj1;
const A*ptr=new A;
ptr=&obj1;
ptr->a=100;
ptr->fun( );
}
第3题:
下列程序的执行结果是______。
include<iostream.h>
include<iomanip.h>
using namespace std;
voidmain()
{
cout<<setfill('x')<<setw(10);
cout<<"Hello"<<end1;
}
第4题:
下列程序的输出结果是【 】。
include<iostream.h>
include<string.h>
void main(){
char b[30];
strcpy(&b[0],"XY");
strcpy(&b[1],"YZW");
strcpy(&b[2],"ZXY");
cout<<b<<end1;
}
第5题:
以下程序的执行结果是【 】。
include <iostream.h>
include <fstream.h>
include <stdlib.h>
int main()
{
fstream outfile, infile;
outfile.open("D:\\text.dat",ios::out);
if(!outfile)
{
cout<<"text.dat can't open"<<end1
第6题:
下列程序不能通过编译,应该在划线部分填写的语句是【 】。
include<iostream. h>
include<stdlib. h>
double Fune(int a, int b, char ch)
{
double x;
switch(ch)
{
case '+':
x=double(a) +b;
break;
case '--':
x= double(a) --b;
break;
case '/':
x=double(a) * b;
break;
case '/':
if(B) x=double(a) /b;
else
exit(1)
break
default:
exit(1);
}
______
}
void main()
{
cout<<Func(32 , 6 ,'--')<< ",";
cout<<Func(32, 6 ,'*') <<",";
cout<<Func(32, 6 ,'/') <<end1;
}
第7题:
下列程序编译时发现pb->f(10);语句出现错误,其原因是______。
include<iostream.h>
class Base
{
public:
void f(int x){cout<<"Base:"<<x<<endl;)
};
class Derived:public Base
{
public:
void f(char*str){cout<<"Derived:"<<str<<endl;}
};
void main(void)
{
Derived*pd=new Derived;
Pd->f(10);
}
第8题:
下面程序错误的语句是 #include"iostream.h" ① void main() ② { ③ int A=0; ④ int&B; ⑤ B=A; ⑥ cout<<B; ⑦ cout<<A; ⑧ }
A.②
B.③
C.④
D.⑥
第9题:
下面程序错误的语句是
①#include<iostream.h>
②void main()
③{
④ int * p=new int[1]
⑤ p=9
⑥ cout<<* p<<end1;
⑦ delete []p;
⑧}
A.④
B.⑤
C.⑥
D.⑦
第10题:
下列程序编译错误,是由于划线处缺少某个语句,该语句是______。
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);
}
第11题:
下列程序不能通过编译,应该在划线部分填写的语句是_______。
第12题:
#include< iostream.h >命令中,include的意义是:()。
第13题:
下面程序错误的语句是
① #include<iostream.h>
② void main( )
③ {
④ int * p=new int[1] ;
⑤ p=9;
⑥ cout < < * p < <endl;
⑦ delete[ ] p;
⑧ }
A.④
B.⑤
C.⑥
D.⑦
第14题:
下面程序的执行结果是______。
include<iostream.h>
include<iomanip.h>
using namespace std;
void main()
{
cout<<setfill('x')<<setw(10);
cout<<"Hello"<<endl;
}
第15题:
应在下面程序下划线中填写的正确的语句是( )。 #include <iostream> using namespace std; class A{ public: void test(){cout<< "this is A!";} }; class B:public A{ void test(){ ______ //显示调用基类函数test() cout<< "this is B!"; } }; void main(){}
A.A::test()
B.test()
C.B::test()
D.this->test()
第16题:
下列程序完成从文件读取文件显示的同时写入第二个文件,则在程序中划线部分应该出现的语句是______。
include<iostream.h>
include(fstream.h)
void main()
{
fstream filel,file2;
charfnl[10],fn2[10],ch;
cout<<“输入源文件名”;
cin>>fnl;
cout<<“输入目标文件名”;
cin>>fn2;
filel.open(fnl,ios::i
第17题:
有以下程序 #include<iostream.h> void main() {int a=5,b=0,c=0; if(a=b+c)cout<<"***"<<endl; else cout<<"$$$"<<<endl;} 下列选项叙述正确的是( )。
A.有语法错不能通过编译
B.可以通过编译但不能通过连接
C.输出***
D.输出$$$
第18题:
下面程序错误的语句是 #include“iostream.h” ① void main( ) ② { ③ int A=0; ④ int &B; ⑤ B=A; ⑥ cout<<B; ⑦ cout<<A; ⑧ }
A.②
B.③
C.④
D.⑥
第19题:
下列程序用于将源文件中的字母进行大小写转换,请填写while的请句。
include<iostream.h>
include<fstream.h>
include<iomanip.h>
void main()
{
char ch;
fstream file1,file2;
char fnl[10],fn2[10];
cout<<“输入源文件名:”;
cin>>fn1;
cout<<“输入目标文件名:”;
cin>>fn2;
{i
第20题:
对于下面的程序,说法正确的是 #include<iostream.h> void main( ) { int x=3,y=4,z=2; if(X=y+z) cout <<"x=y+Z"; else cout<<"x!=y+Z";}
A.不能通过编译
B.输出6
C.输出x! =y+z
D.输出x=y+z
第21题:
有以下程序 #include<iostream.h> void main( ) { int a=5,b=0,c=0; if(a=b+c) cout<<"* * *" <<endl; else cout<<"$$$"<<endl;} 下列选项叙述正确的是
A.有语法错不能通过编译
B.可以通过编译但不能通过连接
C.输出* * *
D.输出 $ $ $
第22题:
请在下列程序的横线处填写正确的语句。
include<iostream>
using namespace std;
class Base{
public:
void fun(){cout<<"Base fun"<<endl;}
};
class Derivde:public Base{
public:
void fun(){
______∥ 调用基类的函数
第23题:
如下程序编译时发生错误,错误的原因是show函数实现语句错误,则正确的语句应该为______。
include<iostream.h>
class test
{
private:
int hum;
public:
test(int);
void show( );
};
test::test(int n){num=n;}
test::show( ){cout<<num<<endl;}
void main( )
{
test T(10):
T.show( );
}