有以下程序:
#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:程序编译时出错
有如下程序:#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
有以下程序 #include <iostream> #include <string> using namespace std; class base { private: char baseName[10]; public: base ( ) { strcpy(baseName,"Base"); } virtual char *myName( ) { return baseName; } char *className( ) { return baseName; } }; class Derived : public base { private: char derivedName[10]; public: Derived( ) { strcpy(derivedName,"Derived"); } char *myName( ) { return derivedName; } char *className( ) { return derivedName; } }; void showPtr(base &p) { cout<<p.myName ( ) <<" "<<p.className ( ); } int main ( ) { base bb; Derived dd; showPtr(dd); return 0; } 运行后的输出结果为
A:Derived Base B:Base Base C:Derived Derived D:Base Derived
有如下程序: #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
有以下程序 #include <iostream> #include <string> using namespace std; class base { private: char baseName[10]; public: base( ) { strcpy(baseName,"Base"); } virtual char *myName( ) { return baseName; } char *className( ) { Return baseName; } }; class Derived: public base { private: char derivedName[10]; public: Derived( ) { strcpy(derivedName,"Derived" ); } char *myName( ) { return derivedName; } char *className( ) { return derivedName; } }; void showPtr(base &p) { cout<<p.myName( )<<" "<<p.className( ); } int main( ) { base bb; Derived dd; showPtr(dd); return 0; } 运行后的输出结果为
A:Derived Base B:Base Base C:Derived Derived D:Base Derived
有以下程序 #include<iostream> #include<string> using namespace std; class base { private: charbaseName[10]; public: base( ) { strcpy(baseName,"Base"); } virtual char*myName( ) return baseName; } char *className( ) { return baseName; } }; class Derived: public base { private: char derivedName[10]; public: Derived( ) { strcpy(derivedName,"Derived"); } char *myName( ) { return derivedName; } char *className( ) { return derivedName; } }; void showPtr(base &p) { cout<<p.myName0<<" "<<p.className( ); } int main( ) { base bb; Derived dd; showPtr(dD) ; retum 0; } 动行后的输出结果为
A:Derived Base B:Base Base C:Derived Derived D:Base Derived
有如下程序: #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