图片.png
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
class Protocol {
public:
virtual void sailBook() = 0;
};
class RealStore :public Protocol {
public:
virtual void sailBook() {
cout<<"卖书"<<endl;
}
};
class TaobaoProxy :public Protocol {
public:
Protocol* protocol;
TaobaoProxy(Protocol* protocol) {
this->protocol = protocol;
}
virtual void sailBook() {
protocol->sailBook();
cout << "淘宝代理卖书" << endl;
}
};
void main() {
RealStore* r = new RealStore;
TaobaoProxy* t = new TaobaoProxy(r);
t->sailBook();
delete t;
delete r;
system("pause");
}
网友评论