有如下程序:
#include
using namespace std;
class ONE
{
public:
virtual void f(){cout<<"l";}
};
class TWO:public ONE
{
public:
TWO(){cout<<"2";}
};
class THREE:public TWO
{
public:
virtual void f(){TWO::f(); cout<<"3";}
};
int main()
{
ONE aa, *p;
TWO bb;
THREE cc;
p = &cc;
p->f();
return 0;
}
执行上面程序的输出是 【 11 】 。
第1题:
有如下程序:
#include<iostream>
using narnespace std;
class ONE{
int e;
public:
ONE():c(O){cout<<1;)
ONE(int n):c(13){cout<<2;}
};
class TWO{
ONE oriel;
ONE one2,
public:
TWO(int m):one2(m){cout<<3;}
};
int main(){
TWO t(4);
return O;
}
运行时的输出结果是
A.3
B.23
C.123
D.213
第2题:
请将如下程序补充完整,使得输出结果为: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;
}
第3题:
第4题:
有如下程序: #include<iostream>#include<iosream> using namespace std; class BASE{ char c; public; BASE(char n):c(n){} virtual ~ BASE(){cout<<c;} }; class DERIVED; public BASE{ char c; public: DERIVED (char n): BASE (n+1)
A.XY
B.YX
C.X
D.Y
第5题:
有如下程序: #include<iostream> using namespace std; class B{ public: Virtual void show(){cout<<“B”;} }; class D:publicB{ public: void show(){cout<<“D”;} }; void funl(B*ptr){ptr->show();} void{un2(B&ref){ref.show();} void
A.BBB
B.BBD
C.DBB
D.DBD
第6题: