程序的输出结果是【 】。
include <iostream>
using namespace std;
class A{
public:
A(){a=b=2;}
A(int i,int j){a=i;b=j;}
void display(){cout<<a<<b;}
private:
int a,b;
};
void main(){
A m,n(4,8);
m.display();
n.display();
}
第1题:
下面程序的输出结果是【 】。
include <iostream>
using namespace std;
class A
{
int a, b;
public:
A()
{
a = b = 0;
}
A(int aa, int bb ) : a(aA) , b(bB)
{
cout <<"a="<<a<<","<<"b="<<b<<",";
}
~A()
{
cout<<"D";
};
int main ( )
{
A x, y(2, 3);
return 0;
}
第2题:
有如下程序:
include<iostream>
using namespaee std;
class A{
public:
A( ){cout<<"A";}
~A( ){cout<<"A";}
};
class B{
A a;
public:
B( ){cout<<"B";}
~B( )t cout<<"B";}
};
int main( ){
B b;
return 0;
}
程序的输出结果是______。
第3题:
下面程序的输出结果是( )。 #include <iostream> using namespace std; class A { public: A( ) {cout<<"A";} } class B { public: B() {coat<<"B" ;} } class C: public A { public: B b; C() {cout<<"C";} } void mian(){ C c; }
A.CBA
B.ABC
C.ACB
D.BCA
第4题:
请将如下程序补充完整,使得输出结果为:bbaa。
include<iostream>
using naluespace std;
class A{
public:
______{eout<<"aa";}
};
class B:public A{
public:
~B( ){eont<<"bb";}
};
int ulain( ){
B*P=new B;
delete P;
return 0;
}
第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