C++超市商品管理系统

2020-09-24 社会 61阅读
class Commodity
{
    public:
    Commodity(string name,float price,int num,string producer,string brand);
    void setNum(int num);
    int getNum();
    void setPrice(double price);
    double getPrice();
    private:
    string name;
    float price;
    int num;
    string producer;
    string brand;
};
Commodity::Commodity(string name,float price,int num,string producer,string brand)
{
    
    this->name=name;
    this->price=price;
    this->num=num;
    this->producer=producer;
    this->brand=brand;
}
void Commodity::setNum(int num)
{
    this->num=num;
}
int Commodity::getNum()
{
    return num;
}
void Commodity::setPrice(double price)
{
    this->price=price;
}
double Commodity::getPrice()
{
    return price;
}
Commodity foods=Commodity("食品"1.00,200,"生产商一","品牌一");
Commodity cosmetic=Commodity("化妆品"25.0,200,"生产商一","品牌一");
Commodity goods=Commodity("日用品"2.00,200,"生产商一","品牌一");
Commodity baverage=Commodity("饮料"2.50,200,"生产商一","品牌一");
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com