万能百科  > 所属分类  > 

如下程序的输出结果是______。 include using namespace std; class Pet{ char nam

如下程序的输出结果是______。

include<iostream>

using namespace std;

class Pet{

char name[10];

public:

Pet(char*nanle){strcpy(this->name,name);}

const char*getName( )const{return name;}

virtual void call( )eonst=0;

};

class Dog:public Pet{

public:

Dog(char*name):Pet(name){ }

void call( )eonst{cout<<"汪汪叫";}

};

class Cat:public Pet{

public:

Cat(char*name):Pet(name){ }

void call( )const{eout<<"喵喵叫";}

};

int main( ){

Pet*petl=new Dog("哈克"),*pet2=new Cat("吉米");

eout<<petl->getName( );petl->call( );eout<<endl;

cout<<pet2->getName( );pet2->call( );eout<<endl;

return 0;

}

正确答案:

哈克汪汪叫 吉米喵喵叫哈克汪汪叫 吉米喵喵叫

词条内容仅供参考,如果您需要解决具体问题
(尤其在法律、医学等领域),建议您咨询相关领域专业人士。

标签