下面程序输出的结果是【 】。
include <iostream>
using namespacc std;
class A {
public:
void show(){tout<<"A!";}
};
class B: public A{
public:
virtual void show(){cout<<"B!";}
};
class C: public B{
public:
virtual void show(){cout<<"C!";}
};
void show_info(A *i){i->show();}
void main(){
A ia;B ib;C ic;show_info(&ia); show_info(&ib);show_info(&ic);
}
第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,h> class example { int a; public: example(int b) {a=b++;} void print( ){a=a+1;cout<<a<<"";} void print( )const{cout<<a<<"";} }; void main( ) { example X(3);
A.22
B.43
C.42
D.32
第3题:
下面程序输出的结果是( )。 #include<iostream> using namespace std; class A{ int X; public: A(int x):x(++x){} ~A(){cout<<x;} }; class B:public A{ int y; public: B(int y):A(y),y(y){} ~B(){cout<<y;}; }; void main(){ B b(3); }
A.34
B.43
C.33
D.44
第4题:
下面程序输出的结果是【 】。
include <iostream>
using namespace std;
class A {
public:
virtual void show() {cout<<"A!";
};
class B: public A {
public:
void show() {cout << "B!";}
};
class C: public B{
public:
void show(){cout << "C!";}
};
void show_info(A &i) {i. show();}
void main() {
A ia; B ib; C ic; show_info(ia);show_info(ib); show_info(ic); }
第5题:
下面程序的输出结果是( )。 #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