下面代码有何错误
void func2(int *value)
{
*value = 2;
}
void func1()
{
int *p = 0;
func2(p);
}
第1题:
下列程序执行后的输出结果是
void funcl(int i);
void func2(int i);
char st[]="hello,friend!";
void fund(int i)
{ cout<<st[i];
if(i<3){i+=2;func2(i);}
}
void func2(int i)
{ cout<<st[i];
if(i<3){i+=2;funcl(i);}
}
main( )
{int i=0;fund(i);cout<<endl;}
A.hello
B.hel
C.hlo
D.hlm
第2题:
下列程序执行后的输出结果是______。
A.hello
B.hel
C.hlo
D.hlm void func1 (int i); void func2 (int i); char st[]="hello,friend!"; void func1(int i) { printf("%c",st[i]); if(i<3){ i+=2;func2(i); } } void func2 (int i) { printf("%c",st[i]); if(i<3){ i+=2;func1(i); } } main() { int i=0;func1(i);printf("\n");}
第3题:
写出下列代码的输出内容
#include
int inc(int a)
{
return(++a);
}
int multi(int*a,int*b,int*c)
{
return(*c=*a**b);
}
typedef int(FUNC1)(int in);
typedef int(FUNC2)(int*,int*,int*);
void show(FUNC2 fun,int arg1, int*arg2)
{
INCp=&inc;
int temp =p(arg1);
fun(&temp,&arg1, arg2);
printf("%d\n",*arg2);
}
main()
{
int a;
show(multi,10,&a);
return 0;
}
第4题:
下列程序执行后的输出结果是( )。 #include<stdio.h> void func1(int i); void func2(int i); char st[]="hello,friend!"; void funcl(int i) { printf("%c",st[i]); if(i<3){i+=2;func 2(i);} } void func 2(int i) { printf("%c",st[i]); if(i<3){i+=2;funcl(i);} } main() { int i=0; funcl(i);printf("\n"); }
A.hello
B.hel
C.hlo
D.hlm
第5题:
下列程序执行后的输出结果是( )。 void func1 (int i); void func2(int i); char st[]="hello,friend!"; void func1 (int i) { printf("%c",st[i]); if(i<3){i+=2;func2(i);} } void func2(int i) { printf("%c",st[i]); if(i<3){i+=2;func1(i);}
A.hello
B.hel
C.hol
D.hlm
第6题:
int func1(int& b)
{
return 0;
}
void func2()
{
int bbb = 3;
func1(&bbb);
func1(bbb);
}
func2中有何错误,func1的参数b 的类型是什么。
第7题:
有下列程序void func1(int i);void func2(int i);char st[ ]="hello,friend! ";void func1(int i){ printf("%c",st[i]); if(i<3){i+=2;func2(i);}}void func2(int i){ printf("%c",st[i]); if(i<3){i+=2;func1(i);}}main(){ int i=0;func1(i); printf("\n");}执行后的输出结果是A.hello B.helC.hlo D.hlm
第8题:
下面类的定义,有( )处错误。 class MyClass { public: void MyClass(); ~MyClass(int Value); private: int i=0; };
A.1
B.2
C.3
D.4
第9题:
有下列程序: #inClude<iostream> using namespace std; c1ass A{ pubic: virmal void func1(){cout<<"A1";} void func2(){cout<<"A2";} }; c1ass B:public A{ publIc: void func1(){cout<<"B1";} void func2(){cout<<"B2"
A.B182
B.A1A2
C.B1A2
D.A182
第10题:
有如下程序: #include<iostream> using namespace std; class Base{ public: virtual void func1(){cout<<"Base 1";} void rune2(){cout<<"Base 2";} }; class Derived:public Base{ public: void func1(){cout<<"Derived 1";} void func2(){cout<<"Derived 2";} }; int main(){ Base *p=new Derived; P->func1(); P->func2(); return 0: } 运行此程序,屏幕上将显示输出______。
A.Derived 1 Base 2
B.Base 1 Base 2
C.Derived 1 Derived 2
D.Base 1 Derived 2
第11题:
对于类定义 class A { public: virtual void funcl(){} void func2(){} }; class D:public A{ public: void funcl(){cout<< "class B rune 1"<<end1;} virtual void func2(){cout<< "class B func 2"<<end1;} }; 下面正确的叙述是 ______。
A.A::func2()和B::funcl()都是虚函数
B.A::func2()和B::funcl()都不是虚函数
C.B::func1()是虚函数,而A::func2()不是虚函数
D.B::func1()不是虚函数,而A::func2()是虚函数
第12题:
Given the following interface definition, which definitions are valid?() interface I { void setValue(int val); int getValue(); } DEFINITION a: (a) class a extends I { int value; void setValue(int val) { value = val; } int getValue() { return value; } } DEFINITION b: (b) interface b extends I { void increment(); } DEFINITION c: (c) abstract class c implements I { int getValue() { return 0; } abstract void increment(); } DEFINITION d: (d) interface d implements I { void increment(); } DEFINITION e: (e) class e implements I { int value; public void setValue(int val) { value = val; } }
第13题:
有如下程序#include <iostream>using namespace std;class A{public:virtual void func1 (){ cout<<"A1"; }void func2(){ cout<<"A2"; }};class B: public A{public:void func l(){ cout<<"B1"; }void func2(){ cout<<"B2"; }};int main() {A *p=new B;p->func1();p->func2();return 0;}运行此程序,屏幕上将显示输出( )。
A.B1B2
B.A1A2
C.B1A2
D.A1B2
第14题:
下列程序执行后的输出结果是 void funcl(int i); void func2(int i); char st[]="hello,friend!"; void funcl(int i) {printf("%c",st[i]); if(i<3){i+=2;func2(i);}} void func2(int i) { printf("%c",st[i]); if(i<3){i+=2;func1(i);}} main() {int i=
A.hello
B.hel
C.hlo
D.hlm
第15题:
有如下程序void func1(int st[],int i){ printf("%c",st[i]); if(i}void func2(int st[],int i){ printf("%c",st[i]); if(i}main(){ char st[ ]="hello,friend! "; int i=0;func1(st,i); printf("\n");}程序执行后输出的结果是A.hello B.hel C.hlo D.编译出错
第16题:
下面程序执行后的结果是( )。 #include<iostream> using namespace std; void func1(int i); void func2(int i); char st[]="hello, friend!"; void func1(int i) { cout<<st[i]; if(i<3){i+=2;func2(i);} } void func2(int i) { cout<<st[i]; if(i<3){i+=2;func1(i);} } void main() { int i=0;func1(i);cout<<endl;}
A.ello
B.hel
C.hlo
D.him
第17题:
下面代码有何错误
void func1()
{
int *pa = NULL;
func2(pa);
delete pa;
}
void func2(int *pb)
{
pb = new int(5);
}
第18题:
有如下程序: #include<iostream> using namespace std; class A{ public: virtual void func1(){cout<<"A1";} void func2(){cout<<"A2";} }; class B:public A{ public: void func1(){cout<<"B1";} void func2(){cout<<"B2";} }; int main() { A *p=new B; p->func1(); p->func2(); return 0; } 执行该程序,屏幕上将显示输出( )。
A.B1B2
B.A1A2
C.B1A2
D.A1B2
第19题:
下列程序 void func1(int i); void func2(int i) char st[]="hello,friend!"; void funcl(int i) { printf("%c",st[i]); if(i<3){i+=2;func2(i);} } void func2(int i) { printf("%c",st[i]); if(i<3){i+=2;funcl(i);} } main() { int i=0;funcl(i);printf("\n");} 执行后的输出结果是( )
A.hello
B.hel
C.hlo
D.hlrn
第20题:
对于类定义 class A{ public: virtual void func1( ){} void func2( ){} }; class B:public A{ public: void func1( ){cout<<"class B func 1"< < end1;} virtual void func2( ){cout << "class B func2"<< end1;} }; 下面正确的
A.A::func2( )和B::func1( )都是虚函数
B.A::func2( )和B::func1( )都不是虚函数
C.B::func1( )是虚函数,而A::func2( )不是虚函数
D.B::func1( )不是虚函数,而A::func2( )是虚函数
第21题:
下列程序的运行结果是( )。 #include<iostream.h> class Loeation{ private: int X,Y; public: void init(int=0,int=0); void valueX(int val){X=val;} int valueX{returnx;} void valueY(int val){Y=val;} int valueY{return Y;}}; void Location::init(int initX,int initY) {X=initX; Y=initY4} void main(X {Location A,B; A.init; B.value X(5); cout<<A.value X<<endl<<A.value Y<<endl; B.init(6,2); B.value Y(4); eout<<B.value X<<endl<<B.value Y<<endl; }
A.5 0 6 4
B.0 0 6 4
C.5 0 6 2
D.0 0 6 2
第22题:
有如下程序: #include<iostream> using namespace std; class A{ public: virtual void fancl{cout<<”Al”;} void func2{cout<<”A2”;} }; class B:public A{ public: void funcI{tout<<”Bl”;} void func2{tout<<”B2”;} }; intmain} A*P=new B: P—>funcl; P—>func2; delete p; return 0; } 执行这个程序的输出结果是( )。
A.B182
B.A1A2
C.B1A2
D.AIB2
第23题: