using?namespace?std;
class?Animal{
private:
int?m_wight;
public:
Animal(int?w){
m_wight=w;
}
void?getWight(){
?cout<<"my?wight?is?"<<m_wight<<"."<<endl;
}
};
class?Horse:public?Animal{
public:
Horse(int?w):Animal(w){
}
void?run(){
cout<<"i?can?run!"<<endl;
}
};
class?Bird:public?Animal{
public:
Bird(int?w):Animal(w){
}
void?fly(){
cout<<"i?can?fly!"<<endl;
}
};
class?Pegasue:public?Horse,public?Bird{
public:
Pegasue(int?w):Horse(w),Bird(w){
}
void?print(){
cout<<"I'm?a?Pegasue!"<<endl;
Horse::getWight();
Horse::run();
Bird::fly();
}
};
int?main(){
int?wight;
cin>>wight;
Pegasue?p1(wight);
p1.print();?
}
Dev C++ 測試通過