日新月异
5
公司 :杭州神话信息技术有限公司
部门 :运营中心设计部
岗位 :UI视觉设计
8
关注
15
粉丝
7030
微博
56
被赞
新浪微博
原创达人
友情链接:
找感兴趣的人
精彩内容
热门应用
关于我们
手机玩微博
include<iostream>
using namespace std;
class Pet{
char name;
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;
}
正确答案:哈克汪汪叫 吉米喵喵叫哈克汪汪叫 吉米喵喵叫