下面代码有何错误
void func1()
{
int *pa = NULL;
func2(pa);
delete pa;
}
void func2(int *pb)
{
pb = new int(5);
}
第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题:
有如下程序#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
第3题:
下列程序执行后的输出结果是
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.hel
C.hlo
D.hlm
第4题:
下面程序编译时发现ma[3]=9错误,其原因是______。
include<iostream.h>
class FunArray
{
int*pa; //指向一个数组空问
int size; //数组元素个数
public:
FunArray(int a[],int thesize):pa(a),size(thesize){}
int Size( ){return size;}
}
};
void main( )
{
int s[]={3,7,2,1,5,4};
FunArray ma(s,sizeof(s)/sizeof(int));
ma[3]=9;
cout<<ma[3]<<endl;
}
第5题:
已知一个类A,类A有三个公有成员:void f1(int),void f2(int)和int a;定义指向类A成员函数的指针是( )。
A.A*p;
B.int A::*Pc=&A.a;
C.void(A::*pA) ();
D.void(A::*p
第6题:
已知一个类Sample,( )是定义指向类Sample成员函数的指针,假设类有三个公有成员:voidf1(int),void f2(int)和int a。
A.Sample*p
B.Int Samale::*pc=&Sample::a
C.Void(Sample::*Pa)()
D.Sample*P[10]
第7题:
下列程序执行后的输出结果是______。
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");}
第8题:
( 35 ) 有如下程序
#include
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
第9题:
下列程序执行后的输出结果是 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
第10题:
已知一个类Sample,( )是定义指向类Sample成员函数的指针,假设类有三个公有成员:voidfl(int),void f2(int)和int a。
A.Sample*p
B.Int Samale::*pc=&Sample::a
C.Void (Sample::*Pa) ()
D.Sample *P[10]