class的一个小项目(未完成,只把class写了)

望一键三连! 

#include <iostream>
#include <string>
using namespace std;
class building
{
private:
    int floor;
    unsigned short history;
    string name;
    double area;
public:
    building()
    {
        floor=0;
        history=0;
        name="";
        area=0.0;
    }
    building(string n):
    name(n) {}
    building(int f,unsigned short h,string n,double a):
    floor(f),history(h),name(n),area(a) {}
    void SetFloor(building&bd)
    {
        cin>>bd.floor;
    }
    void SetHistory(building&bd)
    {
        cin>>bd.history;
    }
    void SetArea(building&bd)
    {
        cin>>bd.area;
    }
    void SetName(building&bd)
    {
        cin>>bd.name;
    }
    void SetFloor1(int f)
    {
        floor=f;
    }
    void SetHistory1(unsigned short h)
    {
        history=h;
    }
    void SetArea1(double a)
    {
        area=a;
    }
    void SetName1(string n)
    {
        name=n;
    }
    int GetFloor(building&bd)
    {
        return bd.floor;
    }
    unsigned short GetHistory(building&bd)
    {
        return bd.history;
    }
    string GetName(building&bd)
    {
        return bd.name;
    }
    double GetArea(building&bd)
    {
        return bd.area;
    }
};
class BuildingPlan:public building
{
private:
    unsigned int day;
    string NameOfA;
    string NameOfB;
public:
    BuildingPlan()
    {
        SetFloor1(0);
        SetName1("");
        SetHistory1(0);
        day=0;
        NameOfA="";
        NameOfB="";
    }
    BuildingPlan(int f,string n,unsigned short h,double area,int d,string a,string b):
    day(d),NameOfA(a),NameOfB(b)
    {
        SetFloor1(f);
        SetName1(n);
        SetHistory1(h);
    }
    void SetDay(BuildingPlan&bd)
    {
        cin>>bd.day;
    }
    void SetNameOfA(BuildingPlan&bd)
    {
        cin>>bd.NameOfA;
    }
    void SetNameOfB(BuildingPlan&bd)
    {
        cin>>bd.NameOfB;
    }
    unsigned int GetDay(BuildingPlan&bd)
    {
        return bd.day;
    }
    string GetNameOfA(BuildingPlan&bd)
    {
        return bd.NameOfA;
    }
    string GetNameOfB(BuildingPlan&bd)
    {
        return bd.NameOfB;
    }
};
int main()
{
    building bd;
    BuildingPlan bdp;
    bd.SetFloor(bd);
    bd.SetHistory(bd);
    bd.SetName(bd);
    bd.SetArea(bd);
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值