有如下程序:
include <iostream>
using namespace std;
class ONE
{
public:
virtual void f() { cout << "1"; }
};
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;
}
执行上面程序的输出是【 】。
第1题:
有如下程序: #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
第2题:
有以下程序: #include <iostream> using namespace std; class BASE { private: char c; public: BASE(char n):c(n);{} virtual~BASE() { cout<<c; } }; class DERIVED:public BASE { char c; p
A.XY
B.YX
C.X
D.Y
第3题:
第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 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