程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> ´ó»°Éè¼ÆģʽC++ʵÏÖ-µÚ22ÕÂ-ÇŽÓģʽ

´ó»°Éè¼ÆģʽC++ʵÏÖ-µÚ22ÕÂ-ÇŽÓģʽ

編輯:C++入門知識

´ó»°Éè¼ÆģʽC++ʵÏÖ-µÚ22ÕÂ-ÇŽÓģʽ


Ò»¡¢UMLͼ

\


¶þ¡¢¸ÅÄî

ÇŽÓģʽ£¨Bridge£©£º½«³éÏ󲿷ÖÓëËüµÄʵÏÖ²¿·Ö·ÖÀ룬ʹËûÃǶ¼¿ÉÒÔ¶ÀÁ¢µØ±ä»¯¡£


<†·Ÿ"http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+PHN0cm9uZz7I/aGiy7XD9zwvc3Ryb25nPjwvcD4KPHA+PHN0cm9uZz7Oqsqyw7S90KGwx8W908Sjyr2hsaO/PC9zdHJvbmc+PC9wPgo8cD7I58nPy/nKvrXEVU1MzbzW0KOs09DSu7j2vtu6z8/fo6zP8dK71/nHxaOsy/nS1L3QobDHxb3TxKPKvaGxoaM8L3A+CjxwPjxicj4KPC9wPgo8cD48c3Ryb25nPrjFxO694srNo7o8L3N0cm9uZz48L3A+CjxwPsqyw7S90LPpz/PT68v8tcTKtc/Wt9bA66Os1eKyorK7ysfLtaOsyMOz6c/zwODT68bkxcnJ+sDgt9bA66Os0vLOqtXiw7vT0MjOus7S4tLloaPKtc/W1ri1xMrHs+nP88Dg0+vL/LXExcnJ+sDg08PAtMq1z9bX1Ly6tcS21M/zoaM8L3A+CjxwPjxicj4KPC9wPgo8cD48c3Ryb25nPs6qyrLDtNKq08XPyMq508O6z7PJL77bus/UrdTyo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PQ=="brush:java;">#ifndef BRIDGE_H #define BRIDGE_H #include #include //Implementor£º´Ë´¦ÎªÊÖ»úÈí¼þ³éÏóÀà class HandsetSoft { public: virtual void Run()=0; }; //ConcreteImplementorA£¬´Ë´¦ÎªÊÖ»úÓÎÏ· class HandsetGame:public HandsetSoft { void Run() { std::cout<<"ÔËÐÐÊÖ»úÓÎÏ·"<soft=soft; } virtual void Run()=0; }; //RefineAbstraction£¬´Ë´¦ÎªÊÖ»úÆ·N class HandsetBrandN:public HandsetBrand { public: void Run() { soft->Run(); } }; //RefineAbstraction£¬´Ë´¦ÎªÊÖ»úÆ·M class HandsetBrandM:public HandsetBrand { public: void Run() { soft->Run(); } }; #endif

£¨2£©Client.cpp

#include "Bridge.h"
#include 
#include 

//Client£¬¿Í»§¶Ë
void main()
{
	//ÊÖ»úÆ·ÅÆN
	std::cout<<"ÊÖ»úÆ·ÅÆN£º"<SetHandsetSoft(new HandsetGame());
	ab->Run();

	ab->SetHandsetSoft(new HandsetAddressList());
	ab->Run();

	delete ab;

	//ÊÖ»úÆ·ÅÆM
	std::cout<SetHandsetSoft(new HandsetGame());
	ab->Run();

	ab->SetHandsetSoft(new HandsetAddressList());
	ab->Run();

	delete ab;
	ab=NULL;

	std::cout<

£¨3£©ÔËÐнØͼ







  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved