你好,能帮我看一道C++的题目吗?

一名兽医想要记录他所治疗的各种类型的狗及治疗信息,尤其想了解不同的病证对带斑点的狗和不带斑点的狗所产生的影响。为该兽医设计一个类体系,要求记录狗的品种(breed),身高... 一名兽医想要记录他所治疗的各种类型的狗及治疗信息,尤其想了解不同的病证对带斑点的狗和不带斑点的狗所产生的影响。为该兽医设计一个类体系,要求记录狗的品种(breed),身高(height),体重(weight),颜色(colour)等信息。为斑点狗和不带斑点的狗分别设计不同的类。在下面的程序中使用你将定义的类:
int main(void)
{//定义一个白色的Dalmatian斑点狗,它身高24,体重60,斑点为红色
spotted_dog redSpot("Damlmatian",24,60,"white","red");
//定义一个黄色的Labrador Rectriever无斑点狗,它身高30,体重为40
unspotted_dog rover("Labrador Retriever",30,40,"yellow");
redSpot.show_breed();
redSpot.spot_info();
rover.show_breed();
return 0;
}
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;

class unspotted_dog{
protected:
char breed[30];
int height;
int weight;
char colour[10];
public:
unspotted_dog(char* breed,float height,float weight,char* colour)
{strcpy(this->breed,breed);
this->height=height;
this->weight=weight;
strcpy(this->colour,colour);
}
virtual void show_breed()=0;
};

void unspotted_dog::show_breed()
{cout<<"狗的品种为:"<<breed;}

class spotted_dog:public unspotted_dog{
char spotcolour[10];
public:
spotted_dog(char* breed,int height,int weight,char* colour,char* spotcolour)
{strcpy(this->breed,breed);
this->height=height;
this->weight=weight;
strcpy(this->colour,colour);
strcpy(this->spotcolour,spotcolour);
}
void show_breed()
{cout<<"无斑狗的品种为:"<<breed;}
void spot_info() {cout<<"斑点为:"<<colour;}
};

int main(void)
{spotted_dog redSpot("Damlmatian",24,60,"white","red");
unspotted_dog rover("Labrador Retriever",30,40,"yellow");
redSpot.show_breed();
redSpot.spot_info();
rover.show_breed();
return 0;
}
帮我看看这程序错哪,谢谢
展开
 我来答
匿名用户
推荐于2016-03-12
展开全部
//---------------------------------------------------------------------------

#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
using namespace std;

class unspotted_dog{
protected:
char breed[30];
int height;
int weight;
char colour[10];
public:
unspotted_dog(){}
unspotted_dog(char* breed,float height,float weight,char* colour)
{strcpy(this->breed,breed);

this->height=height;
this->weight=weight;

strcpy(this->colour,colour);
}
void show_breed();
};

void unspotted_dog::show_breed()
{cout<<"狗的品物册种为:"<盯正<breed;}

class spotted_dog:public unspotted_dog{
char spotcolour[10];
public:
spotted_dog(char* breed,int height,int weight,char* colour,char* spotcolour)
{strcpy(this->breed,breed);
this->height=height;
this->weight=weight;
strcpy(this->colour,colour);
strcpy(this->spotcolour,spotcolour);
}
void show_breed()
{cout<<"无斑狗罩则宏的品种为:"<<breed;}
void spot_info() {cout<<"斑点为:"<<colour;}
};

int main(void)
{spotted_dog redSpot("Damlmatian",24,60,"white","red");
unspotted_dog rover("Labrador Retriever",30,40,"yellow");
redSpot.show_breed();
redSpot.spot_info();
rover.show_breed();
return 0;
}

//---------------------------------------------------------------------------
来自:求助得到的回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式