21:发挥自己的想象力吧!
#ifndef FLOWER_H
#define FLOWER_H
#include <string>
using namespace std;
class Flower//花店花朵
{
public:
Flower();//默认构造函数
Flower(const string& s,double sale_pice):name(s),Price(sale_pice){}//构造函数
virtual int net_price() const = 0;//纯虚函数,本身无意义
protected:
double Price;//价格
private:
string name;
};
class Rose:public Flower//普通玫瑰
{
public:
Rose();//
Rose(const string &SR,double n,size_t m):Flower(SR,n),quantity(m){}
int net_price() const
{
return quantity*Price;
}
protected:
size_t quantity;//售量
};
class Discount_Rose:public Rose//打折玫瑰
{
public:
Discount_Rose();//
Discount_Rose(const string &SR,double n,size_