谁能把这段程序补充完整,缺少主程序

来源:百度知道 编辑:UC知道 时间:2024/05/30 03:18:21
要求写一段有继承和派生的C++程序,我写了如下的
人家说没主程序,大家帮我写下主程序,偶是新手,谢谢

#include <iostream.h>
#include <stdio.h>
#include <string.h>

class pet
{
char color[30];
double weight;
int age;
char speak[30];
public:
void color();
{cout<<”pet color”<<endl;}
void weight()
{cout<<”pet weight”<<endl;}
void age()
{cout<<”pet age”<<endl;}
vitual void speak()
{cout<<”pet speak”<<endl;}
};

class cat:public pet
{public:

void speak()
{
cout<<”miao”<<endl;
}
};

/*改了几处错误.VC编译通过*/
#include <iostream.h>
#include <stdio.h>
#include <string.h>

class pet
{
char color[30];
double weight;
int age;
char speak[30];
public:
pet(char *co,double w,int ag,char *sp){/*构造函数*/
strcpy(color,co);
strcpy(speak,sp);
weight=w;
age=ag;
}
~pet(){};
void dispcolor()
{cout<<"pet color:"<<endl;} /*引号用英文字符.*/
void dispweight()
{cout<<"pet weight:"<<endl;}
void dispage()
{cout<<"pet age:"<<endl;}
virtual void dispspeak() /*成员名不能相同*/
{cout<<"pet speak:"<<speak<<endl;}
};

class cat:public pet
{public:
cat(char *co,double w,int ag,char *sp):pet(co,w,ag,sp){};
~cat(){};
void dispspeak()
{
pet::dispspeak() ;
}
};

int main()
{