1, because my home from the railway station is very far, so every time to buy fire tickets are to those selling train ticket agent there to buy train tickets, so the use of proxy mode
2. The proxy mode is generally designed to these nouns
abstract role: Common interface for declaring real objects and proxy objects;
proxy role: The proxy object role contains a reference to the real object, allowing you to manipulate the real object, At the same time, the proxy object provides the same interface as the real object to replace the real object at any moment. At the same time, the proxy object can attach other actions when performing the real object operation, which is equivalent to encapsulating the real object.
real role: The real object represented by the proxy role is the object we end up referencing.
3, actual case
Pan Jinlian find Simon Qing, that Pan Jinlian embarrassed, what to do, find that the king of the agent, performance in the program is such embodiment of
First talk about the elements of this scene: a type of woman, Pan Jinlian, Wang, we are hypothetical, and then Pan Jinlian to find Simon Qing happy, but Pan Jinlian embarrassed directly, find a Wang Po agent bai.
4, specific code
Abstract role: Real object, proxy object interface class iwoman{public:virtual void mklove () = 0;virtual void watch () = 0;};/ /real Role: The real object represented by the proxy role is the object that we end up referencing, really the character class Panjinlian:p ublic iwoman{public:void mklove () {cout << pan Jinlian in and that man ... "<< Endl;} void Watch () {cout << "Pan Jinlian in a movie with a man" << endl;}};/ /proxy Role: The Proxy object class, the proxy object must contain a reference to the true object, and the proxy object provides the same interface as the real object so that at any time class Wangpo:p ublic iwoman{private:iwoman *women;public: Wangpo () {women = new Panjinlian ();} void Mklove () {women->mklove ();} void Watch () {Women->watch ();}}; int _tmain (int argc, _tchar* argv[]) {//Pan Jinlian, want ML, because embarrassed, so look for the king of the Wangpo wp;//surface look actually is Wang in happy in fact is pan Jinlian in Cool Wp.mklove (); Cin.get (); return 0;}
5, slowly realize .....
Agent mode (proxy)