大家能帮我看看这个程序吗?

来源:百度知道 编辑:UC知道 时间:2024/05/29 20:39:35
一名兽医想要记录他所治疗的各种类型的狗及治疗信息,尤其想了解不同的病证对带斑点的狗和不带斑点的狗所产生的影响。为该兽医设计一个类体系,要求记录狗的品种(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->

//ok

#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(); //纯虚函数是不可以有实体的,,,
};

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

class spotted_dog:public unspotted_dog{
char spotcolour[10];
public:
spotted_dog(char* breed,int height,int weight,char* colour,char* spotcolour)
:unspotted_dog(breed,height,weight,colour)//初始化父类构造函数
{
/* strcpy(this->breed,breed);
this->height=height;
this->weight=weight;