[单选题]

有如下程序: include using namespaee std;class Animal{ public: virtual char*g

有如下程序:

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( ){

D.og d;type(D) ;cout<<"speak";speak(D) ;cout< return 0;

}

程序的输出结果是______。

参考答案与解析:

相关试题

若有如下程序: #include using namespaee std; in

[单选题]若有如下程序: include using namespaee std; int fun() { static int i=0; int s=1;若有如下程序: #include<iostream> using namespaee std; int fun() { static int i=0; int s=1; s+=i; i++; return s; } int main() { int i,a=0; for(i=0;i<5;i++) a+=fun(); cout<<a<<end1; ret

  • 查看答案
  • 有如下程序: include using namespaee std; cla

    [试题]有如下程序: include using namespaee std; class ONE{ public: virtual void f有如下程序:include <iostream>using namespaee std;class ONE{public:virtual void f( ){cout<<"1";}};class TWO:public ONE{public:TWO( )1 cout<<"2";}{;class THREE:public TWO{public:virtua

  • 查看答案
  • 有如下程序:#include using namespace std;class

    [单选题]有如下程序:include using namespace std;class BASE{public:~BASE(){cout<<"BASE";}有如下程序: #include <iostream> using namespace std; class BASE{ public: ~BASE(){cout<<"BASE";} }; class DERIVED:public BASE{ public: ~DERIVED(){cout<<"DERIVED";} }; int main(

  • 查看答案
  • 有如下程序:#include using namespace std;class

    [单选题]有如下程序:include using namespace std;class Base{public:Base(){ cout<<"BB";有如下程序: #include <iostream.h> using namespace std; class Base { public: Base(){ cout<<"BB"; f(); } voidf(){cout <<"Bf"; } }; class Derived: public Base { public: Derived (){c

  • 查看答案
  • 有如下程序:#include using namespace std;class

    [单选题]有如下程序:include using namespace std;class point{intx,y;public:point( int vx,有如下程序:#include <iostream>using namespace std;class point{ int x, y;public: point( int vx, int vy ) { x = vx; y = vy; } point ( ) x = 0; y= 0; } point operator+( point p1 ) { po

  • 查看答案
  • 有如下程序;#include using namespace std;class

    [单选题]有如下程序;include using namespace std;class Base{public;Base(inti){x=i;}void d有如下程序; #include <iostream> using namespace std; class Base { public; Base(inti){x=i;} void dispa0{cout<<x<<',';} private; int x; }; class Derived;public Base { public; Derive

  • 查看答案
  • 有如下程序:#include using namespace std;class

    [单选题]有如下程序:include using namespace std;class A {public: A() {cout<<"A";}};class有如下程序: #include <iostream> using namespace std; class A { public: A() {cout<<"A";} }; class B {public:B() {cout<<"B";}}; class C: public A { Bb; public: C() {cout<<"C";

  • 查看答案
  • 有如下程序:#include using namespace std;class

    [单选题]有如下程序:include using namespace std;class Stack {public: Stack(unsigned n= 1有如下程序: #include <iostream> using namespace std; class Stack { public: Stack(unsigned n= 10):size(n) {rep_=ew int[size]; top=0;} Stack(Stack& s):size(s.size) { rep_=new int[

  • 查看答案
  • 有如下程序:#include using namespace std;class

    [单选题]有如下程序:include using namespace std;class x{protected: int a;public: x() { a有如下程序: #include <iostream> using namespace std; class x { protected: int a; public: x() { a=1; } }; class x1 : virtual public x { public: x1() { a+=1; cout<<a; } };A.1B.123C.24

  • 查看答案
  • 有如下程序:#include using namespace std;Class

    [单选题]有如下程序:include using namespace std;Class x{protected: int a;public: x() {a=有如下程序: #include <iostream> using namespace std; Class x { protected: int a; public: x() { a=1; } }; class x1 : virtual public x { public: x1() { a+=1; cout<<A.1B.123C.242D.244

  • 查看答案
  • 有如下程序: include using namespaee std;class