大家能帮我看看这个程序吗?
来源:百度知道 编辑:UC知道 时间:2024/05/29 20:39:35
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;