有如下程序:
include<iostream>
using namespaee std;c lass Animal{
public:
virtual char*getType( )const{return"Animal";}
virtual char*getVoice( )const{return"Voice";}
};
class Dog:public Animal{
public:
char*getType( )const{return"Dog";}
char*getVoice( )eonst{return"Woof";}
};
void type(Animal&A) {cout<<a.getType( );}
void speak(Animal A) {eout<<a.getVoice( );}
int main( ){
Dog d;type(D) ;cout<<"speak";speak(D) ;cout< return 0;
}
程序的输出结果是______。
第1题:
有如下程序: #include <iostream> using namespace std; class AA { public: virtual void f() { cout<< "AA"; } }; class BB : public AA { public: BB() { cout << "BB"; } }; cla
A.AA
B.AABBCC
C.BBAABBCC
D.BBBBAACC
第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 A { public: virtual~A() { cout<<"call A::~A()"<<endl;} }; class B:public A { char * p; public: B(int i) { p=new char[i];} ~B() { delete(p); cout<<"call B::~B()"; } }; void main() { A * a=new B(8); delete a; }
A.call B::~B()call A::~A()
B.call B::~B()
C.call A::~A()
D.call A::~A()call B::~B()