According to Cheng Jie's big talk mode:
1 //Proxy.cpp: Defines the entry point of the console application. 2 //3 4#include"stdafx.h"5#include <iostream>6#include <string>7 using namespacestd;8 9 classGirlTen { One Public: AGirl (stringName =""): Mname (name) {} - stringGetName () - { the returnMname; - } - Private: - stringMname; + }; - + classGivegift A { at Public: - Virtual voidGivedolls () =0; - Virtual voidGiveflowers () =0; - Virtual voidGivechocolate () =0; - }; - in classPuisuit: PublicGivegift - { to Public: + puisuit (Girl mm): Mgirl (mm) {} - Virtual voidgivedolls () the { *cout<<"Send"<<mgirl.getname () <<"Toys"<<Endl; $ }Panax Notoginseng Virtual voidgiveflowers () - { thecout<<"Send"<<mgirl.getname () <<"Flowers"<<Endl; + } A Virtual voidgivechocolate () the { +cout<<"Send"<<mgirl.getname () <<"Chocolate"<<Endl; - } $ Private: $ Girl Mgirl; - }; - the classProxy: PublicGivegift - {Wuyi Public: the Proxy (Girl mm) - { WuMpuisuit =Newpuisuit (mm); - } About Virtual voidgivedolls () $ { -Mpuisuit->givedolls (); - } - Virtual voidgiveflowers () A { +Mpuisuit->giveflowers (); the } - Virtual voidgivechocolate () $ { theMpuisuit->givechocolate (); the } the Private: thepuisuit*Mpuisuit; - }; in int_tmain (intARGC, _tchar*argv[]) the { thecout<<"Proxy Mode"<<Endl; AboutGirl Girl ("Jiao Jiao"); the Proxy Pro (girl); the Pro. Givedolls (); the Pro. Giveflowers (); + Pro. Givechocolate (); -System"Pause"); the return 0;Bayi}
C + + Design mode-proxy mode