以下程序中,错误的行为
① #include<iostream.h>
② class A
③ {
④ public:
⑤ int n=2;
⑥ A(int val) {cout < < val < < endl;}
⑦ ~A( ) {};
⑧ };
⑨ void main( )
⑩ {
(11) A a (0) ;
(12) }
A.⑤
B.⑥
C.⑦
D.⑩
第1题:
分析以下程序的执行结果【 】。
include <iostream. h>
class S{
int A[10];
public:
int &operator () (int);
};
int &S: :operator() (int x) {
return A[x];
}
void main() {
S a;
int i,j;
for (i=0; i<10; i++)
a(i)=i*2;
for (i=0; i<10; i++)
cout<<a(i)<<" ";
cout<<end1; }
第2题:
如下程序编译时发生错误,错误的原因是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( );
}
第3题:
第4题:
以下程序中,错误的行为
①#include<iostream.h> ②class A ③{ ④ public: ⑤ int n=2; ⑥ A(int val){cout<<val<<end1;} ⑦ ~A(){}; ⑧}; ⑨void main() ⑩{ (11) A a(0); (12)}
A.⑤
B.⑥
C.⑦
D.(11)
第5题: