下列程序的输出结果是 #include<iostream.h> class Myclass{ public:Myclass(int i=0,int j=0) { x=i; y=j; } void show( ) {cout < <"x=" < < x < <" " <"y=" < < y < < endl;} void show( ) const{cout < <"x=" < <" " < <"y=" < < y < < endl;} privated: int x; int y; }; void main( ) { Myclass my1(3,4) ; const my2(7,8) ; my1.show( ) ;my2.show( ) ;}
A.x=4,y=3;x=7,y=8
B.x=3,y=4;x=7,y=8
C.x=7,y=8;x=4,y=3
D.x=8,y=7;x=7,y=8
第1题:
以下程序运行后的输出结果是( )。 #include<iostream.h> void main() { char aft="abbcabbcabbc"; int i=0,j=0,k=0; while(a[i]) { if(a[i]=='a') j++; if(a[i]=='b') k++; i++; } cout<<j<<""<<k<<end1; }
A. 2,6
B.3,5
C.4,7
D.3,6
第2题:
分析以下程序的执行结果【 】。
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; }
第3题:
下列程序的输出结果是 #include<iostream.h> class Myclass{ public:My class(inti=0,int j=0) { x=i; y=j; } void show(){cout<<"x=" <<x<<" " <"y=" <<y<<endl;} void show()const{cout<<"x="<<""<<"y="<<y<<endl;} privated: int x; int y; }; void main() { Myclassmy1(3,4); const my2(7,8); myl.show();my2.show();}
A.x=4,y=3;x=7,y=8
B.x=3,y=4;X=7,y=8
C.x=7,y=8;x=4,y=3
D.x=8,y=7;x=7,y=8
第4题:
下列程序的输出结果是 #include<iostream.h> class Myclass{ public : Myclass( int i=0,int j=0) {x=i; y=j; } void show( ){cout<<"x="<<x<<" "<"y="<<y<<endl;} void show( )const{cout<<"x="<
A.x=4,y=3;x=7,y=8
B.x=3,y=4;x=7,y=8
C.x=7,y=8;x=4,y=3
D.x=8,y=7;x=7,y=8
第5题:
如下程序的输出结果是 #include<iostream> using namespace std; class MyClass{ public: MyClass(int i=0){cout<<1;} MyClass(const MyClass&x)}cout<<2;} }; int main( ){ MyClass objl(1),obj2(2),ohj3(objl); return 0; }
A.112
B.111
C.121
D.113