下面程序编译时发现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;
}
第1题:
下列程序编译时发现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);
}
第2题:
下面程序错误的语句是
①#include<iostream.h>
②void main()
③{
④ int * p=new int[1]
⑤ p=9
⑥ cout<<* p<<end1;
⑦ delete []p;
⑧}
A.④
B.⑤
C.⑥
D.⑦
第3题:
如下程序编译时发生错误,错误的原因是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( );
}
第4题:
下列程序的运行结果是 #inClude<iostream.h> roid fun(int *a,int * b) { int * k; k=a;a=b;b=k;} void main( ) { int a=2004,b=9,* x=&a,* y=&b; fun(x,y); cout < < a < <" " < < b < < end1;}
A.2004 9
B.9 2004
C.0 0
D.编译时出错
第5题:
下面程序的结果为______。
include<iostream.h>
void main()
{
int 3=1,b=2;
bool c=1;
if(a>b)||c)cout<<“true”<<endl;
else
cout<<“false”<<endl;
}