#include<iostream>
using namespace std;
class BookStore
{
public:
virtual void SellBook() = 0;
};
class PhysicBookStore:BookStore
{
public:
virtual void SellBook()
{
cout << "实体店卖书!" << endl;
}
};
class DangDang :BookStore
{
public:
virtual void SellBook()
{
PhysicBookStore *bookstore = new PhysicBookStore;
bookstore->SellBook();
Rebate();
}
private:
void Rebate()
{
cout << "当当网打折销售了!" << endl;
}
};
void main()
{
DangDang *bookstore = new DangDang;
bookstore->SellBook();
delete bookstore;
}
代理模式
最新推荐文章于 2022-06-10 13:42:29 发布