有如下程序:
#include
using namespace std;
class Base
{
public:
void funl(){cout<<"Base\n";}
virtual void fun2(){cout<<"Base\n";}
};
class Derived:public Base
{
public:
void funl(){cout<<"Derived\n";}
void fun2(){cout<<"Derived\n";}
};
void f(Base &
B . {b.funl();b.fun2();}&, lt;, /P>
int main()
{
Derived obj;
f(obj);
return 0;
}
执行这个程序的输出结果是
A . Base Base
B . Base Derived
C . Derived Base
D . Derived Derived
第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{ public: ~BASE() {cout<<"BASE"; } }; class DERIVED: public BASE { public: ~DERIVED() {cout<;"DERIVED"; } }; int main(){DERIVED x; return 0;} 执行后的输出结果是______ 。
A.BASE
B.DERIVED
C.BASEDERIVED
D.DERIVEDBASE
第3题:
第4题:
有如下程序: #include<iostream> using namespace std; class Base { public: void funl{cout<<”Base\n”;} virtual void fun2{eout<<”Base\n”;} }; class Derived:public Base{ public: void funl{eout<<”Derived、n”;} void fura{eout<.<”Derived\n”;} }; void f(Base&B.}b.funl;b.ftm2;} int main { Derived obj; f(obj); return 0; } 执行这个程序的输出结果是( )。
A.Base Base
B.Base Derived
C.Derived Base
D.Derived Derived
第5题:
有以下程序: #include <iostream> using namespace std; class Base { public: Base(){} virtual void who() { cout<<"Base Class"<<end1; } ~Base(){} }; class Derivel : public Base { public: void who() { cout<<"Derivel Class"<<end1; } }; class Derive2 : public Base { public: void who () { cout<<"Derive2 Class"<<end1; } }; int main () { Base *p; Derivel obj1; Derive2 obj2; p=&obj1; p=&obj2; p->who ( ); return 0; } 执行程序后的输出结果是( )。
A.Base Class
B.Derivel Class
C.Derive2 Class
D.程序编译时出错