zuoye

class Student1 : public Student
{
public:
    Student1(int n, string nam, char s, int a, string addr) : Student(n, nam, s)
    {
        age = a;
        address = addr;
    }

    void show()
    {
        cout << "num: " << num << endl;
        cout << "name: " << name << endl;
        cout << "sex: " << sex << endl;
        cout << "age: " << age << endl;
        cout << "address: " << address << endl<<endl;
    }

private:
    int age;
    string address;
};
class RobotB : public RobotA{
public:
    RobotB(string _name, string _skill) : RobotA(_name)
    {
        skill = _skill;
        cout << "RobotB come to the word!" << endl;
    }

    void Bspeak()
    {
        cout << "I'm the second generation of robots, the first generation is " << name << "." << endl;
        cout << "I can " << skill << "." << endl;
    }

    ~RobotB()
    {
        cout << "RobotB leaves the word!" << endl;
    }

protected:
    string skill;
};

class RobotC : public RobotB{
public:
    RobotC(string _name, string _skill1, string _skill2) : RobotB(_name, _skill1)
    {
        skill2 = _skill2;
        cout << "RobotC come to the word!" << endl;
    }

    void Cspeak()
    {
        cout << "I'm the third generation of robots, the first generation is " << name << "." << endl;
        cout << "I can " << skill << ",and " << skill2 << "." << endl;
    }

    ~RobotC()
    {
        cout << "RobotC leaves the word!" << endl;
    }

protected:
    string skill2;
};
class TV{
public:
    TV(string _brand, int _size)
    {
        brand = _brand;
        size = _size;
        cout << "购买电视" << endl;
    }

    void showt()
    {
        cout << "这是我的客厅." << endl;
        cout << "电视品牌是" << brand << ",屏幕大小是" << size << "寸." << endl;
    }

protected:
    string brand;
    int size;
};

class TDesk{
public:
    TDesk(string _shape,string _colour)
    {
        shape=_shape;
        colour=_colour;
        cout<<"购买茶几"<<endl;
    }
    void showd()
    {
        cout << "茶几是" << shape << "形,颜色是" << colour << "色." << endl;
    }
protected:
    string shape;
    string colour;
};

class Droom : public Room{
public:
    Droom(double _area, string _brand, int _size, string _shape, string _colour) : Room(_area), t(_brand, _size), d(_shape, _colour)
    {
        
    }

    TV t;
    TDesk d;
};
class Flower : public Plant
{
private:
    string colour;
public:
    Flower() : Plant(""), colour("") {}
    Flower(string _name,string _colour): Plant(_name),colour(_colour){}
void showf()
{
    if (name == "")
        cout << "no name ";
    else
        cout << name << " ";
    if (colour == "")
        cout << "is no colour." << endl;
    else
        cout << "is " << colour << "." << endl;
}
};

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值