Problem 1471. -- 继承派生(10)--动物类和狗类

1471: 继承派生(10)--动物类和狗类

Time Limit: 10 Sec  Memory Limit: 65535 MB   64bit IO Format: %lld
Submitted: 534  Accepted: 302
[Submit][Status][Web Board]

Description

动物类Mammal私有成员数据包含年龄age和体重weight,均是int类型。Mammal类包含若干成员函数(如下所示)。
class Mammal
{
    private:
        int age,weight;
    public:
        Mammal ();
        Mammal (int a,int w);
        void Show();
};
狗类Dog由Mammal类公有派生而来,包含私有成员数据颜色(int color)。Dog类包含若干成员函数(如下所示)。
class Dog:public Mammal
{
    private:
        int color;
    public:
        Dog();
        Dog(int a,int w,int c);
        Dog(Mammal m,int c);
        Dog(int c);
        Dog(Mammal m);
        void Show();
};
完成上述各成员函数的设计。main函数已给定(如下所示),提交时只需要提交main函数外的代码部分。
int main()
{
    int age,weight,color,cas=0;
    Mammal m0;
    Dog d0;
    cout<<"Mammal0:";    m0.Show();
    cout<<"Dog0:";    d0.Show();
    while(cin>>age>>weight>>color)
    {
        cas++;
        cout<<"Case #"<<cas<<":"<<endl;
        Mammal m1(age,weight);
        Dog d1(age,weight,color);
        Dog d2(m1,color);
        Dog d3(color);
        Dog d4(m1);
        cout<<"Mammal1:";    m1.Show();
        cout<<"Dog1:";    d1.Show();
        cout<<"Dog2:";    d2.Show();
        cout<<"Dog3:";    d3.Show();
        cout<<"Dog4:";    d4.Show();
    }
    return 0;
}

Input

包含多组数据(数据均正确合法)
每组测试数据1行,每行包括3个整数,分别表示年龄、体重和颜色(取值0(黑色)1(白色)2(金色)3(黑白花色))。

Output

每组测试数据输出具体格式详见Sample Output。

Sample Input

3 20 1

Sample Output

Function #1 is called!
Function #1 is called!
Function #4 is called!
Mammal0:0岁/0kg
Function #3 is called!
Dog0:黑色/0岁/0kg
Function #3 is called!
Function #9 is called!
Case #1:
Function #2 is called!
Function #2 is called!
Function #5 is called!
Function #6 is called!
Function #1 is called!
Function #7 is called!
Function #8 is called!
Mammal1:3岁/20kg
Function #3 is called!
Dog1:白色/3岁/20kg
Function #3 is called!
Function #9 is called!
Dog2:白色/3岁/20kg
Function #3 is called!
Function #9 is called!
Dog3:白色/0岁/0kg
Function #3 is called!
Function #9 is called!
Dog4:黑色/3岁/20kg
Function #3 is called!
Function #9 is called!

[Submit][Status][Web Board]