大龍的博客
導航
C++博客
首頁
新隨筆
聯系
聚合
管理
<
2011年5月
>
日
一
二
三
四
五
六
24
25
26
27
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
留言簿
(43)
給我留言
查看公開留言
查看私人留言
收藏夾
ps
(rss)
隨筆檔案
2014年10月 (1)
2014年8月 (4)
2014年6月 (1)
2013年12月 (6)
2013年11月 (2)
2013年10月 (5)
2013年9月 (4)
2013年7月 (1)
2013年6月 (2)
2013年3月 (1)
2013年2月 (20)
2013年1月 (10)
2012年12月 (8)
2012年11月 (5)
2012年10月 (9)
2012年9月 (4)
2012年8月 (16)
2012年7月 (8)
2012年6月 (10)
2012年5月 (11)
2012年4月 (3)
2012年3月 (10)
2012年2月 (6)
2012年1月 (4)
2011年12月 (6)
2011年11月 (16)
2011年10月 (32)
2011年9月 (13)
2011年8月 (6)
2011年7月 (27)
2011年6月 (18)
2011年5月 (12)
2011年4月 (2)
2011年3月 (1)
2011年2月 (5)
2011年1月 (24)
2010年12月 (5)
2010年11月 (2)
2010年10月 (3)
2010年9月 (4)
2010年8月 (7)
2010年6月 (13)
2010年5月 (18)
2010年4月 (21)
2010年3月 (6)
2010年2月 (7)
2010年1月 (7)
2009年12月 (7)
2009年11月 (2)
2009年10月 (8)
2009年9月 (19)
2009年8月 (11)
2009年6月 (28)
2009年5月 (35)
2009年4月 (18)
2009年3月 (24)
2009年2月 (13)
2009年1月 (10)
2008年12月 (2)
2008年11月 (6)
2008年10月 (4)
2008年9月 (11)
2008年8月 (18)
2008年7月 (8)
2008年6月 (19)
2008年5月 (9)
2008年4月 (6)
2008年3月 (2)
2008年2月 (4)
2008年1月 (21)
2007年12月 (14)
2007年11月 (4)
2007年10月 (7)
2007年9月 (17)
2007年8月 (10)
2007年7月 (20)
2007年6月 (11)
2007年5月 (8)
2007年4月 (13)
2007年3月 (2)
2007年2月 (6)
2007年1月 (14)
2006年12月 (23)
2006年11月 (15)
2006年10月 (5)
2006年9月 (4)
文章檔案
2007年11月 (1)
2006年12月 (1)
閱讀排行榜
1.?LinuxShell算術運算(49342)
2.?Windows XP DDK 的有效下載地址(45191)
3.?WinDBG教程(40988)
4.?Android 打包簽名 從生成keystore到完成簽名 -- 轉(40708)
5.?在Cygwin上安裝編輯器vim (39072)
評論排行榜
1.?Windows XP DDK 的有效下載地址(116)
2.?在Cygwin上安裝編輯器vim (24)
3.?(TCP-over-UDP library):基于UDP協議之上實現通用、可靠、高效的TCP協議 ---------- 轉(14)
4.?Compuware DriverStudio V3.2(10)
5.? 經典好書 (10)
常用鏈接
我的隨筆
我的評論
我參與的隨筆
統計
隨筆 - 864
文章 - 2
評論 - 378
引用 - 0
最新評論
1.?re: 安裝Nexus私服
謝謝博主。我剛學搭建nexus,挺不錯的。
--做有為青年
2.?re: 用slf4j+logback實現多功能日志解決方案 --- 轉
謝謝樓主,整個流程非常清楚,照著做了一遍就會了。另外我分享一個logback目前尚存在的bug:當你發現INFO級和ERROR級的日志沒有寫成功時,上下移動一下配置文件中appender的位置就好了。
--welldone
3.?re: LinuxShell算術運算
你這些都驗證過嗎
--是是是
4.?re: 用slf4j+logback實現多功能日志解決方案 --- 轉
寫的非常好!
--Hello
5.?re: (TCP-over-UDP library):基于UDP協議之上實現通用、可靠、高效的TCP協議 ---------- 轉
評論內容較長,點擊標題查看
--pcplayer
常見設計模式的解析和實現(C++)之十六-Strategy模式
作用:
定義一系列的算法,把它們一個個封裝起來, 并且使它們可相互替換.本模式使得算法可獨立于使用它的客戶而變化.
UML結構圖:
解析:
簡而言之一句話,Strategy模式是對算法的封裝.處理一個問題的時候可能有多種算法,這些算法的接口(輸入參數,輸出參數等)都是一致的,那么可以考慮采用Strategy模式對這些算法進行封裝,在基類中定義一個函數接口就可以了.
實現:
1)Strategy.h
/**/
/*
*******************************************************************
????created:????2006/08/06
????filename:?????Strategy.h
????author:????????李創
????????????????
http://m.shnenglu.com/converse/
????purpose:????Strategy模式的演示代碼
********************************************************************
*/
#ifndef?STRATEGY_H
#define
?STRATEGY_H
class
?Strategy;
class
?Context
{
public
:
????Context(Strategy?
*
pStrategy);
????
~
Context();
????
void
?ContextInterface();
private
:
????Strategy
*
?m_pStrategy;
}
;
class
?Strategy
{
public
:
????
virtual
?
~
Strategy()
{}
????
virtual
?
void
?AlgorithmInterface()?
=
?
0
;
}
;
class
?ConcreateStrategyA
????:?
public
?Strategy
{
public
:
????
virtual
?
~
ConcreateStrategyA()
{}
????
virtual
?
void
?AlgorithmInterface();
}
;
#endif
2)Strategy.cpp
/**/
/*
*******************************************************************
????created:????2006/08/06
????filename:?????Strategy.cpp
????author:????????李創
????????????????
http://m.shnenglu.com/converse/
????purpose:????Strategy模式的演示代碼
********************************************************************
*/
#include?
<
iostream
>
#include?
"
Strategy.h
"
Context::Context(Strategy?
*
pStrategy)
????:?m_pStrategy(pStrategy)
{
}
Context::
~
Context()
{
????delete?m_pStrategy;
????m_pStrategy?
=
?NULL;
}
void
?Context::ContextInterface()
{
????
if
?(NULL?
!=
?m_pStrategy)
????
{
????????m_pStrategy
->
AlgorithmInterface();
????}
}
void
?ConcreateStrategyA::AlgorithmInterface()
{
????std::cout?
<<
?
"
AlgorithmInterface?Implemented?by?ConcreateStrategyA\n
"
;
}
3)Main.cpp
/**/
/*
*******************************************************************
????created:????2006/08/06
????filename:?????Main.cpp
????author:????????李創
????????????????
http://m.shnenglu.com/converse/
????purpose:????Strategy模式的測試代碼
********************************************************************
*/
#include?
"
Strategy.h
"
int
?main()
{
????Strategy
*
?pStrategy?
=
?
new
?ConcreateStrategyA();
????Context
*
??pContext??
=
?
new
?Context(pStrategy);
????pContext
->
ContextInterface();
????delete?pContext;
????
return
?
0
;
}
本文來源:http://m.shnenglu.com/converse/archive/2006/08/06/10899.aspx
posted on 2006-09-22 18:17
大龍
閱讀(203)
評論(0)
編輯
收藏
引用
只有注冊用戶
登錄
后才能發表評論。
【推薦】100%開源!大型工業跨平臺軟件C++源碼提供,建模,組態!
網站導航:
博客園
IT新聞
BlogJava
博問
Chat2DB
管理
Powered by:
C++博客
Copyright © 大龍
久久无码专区国产精品发布
|
激情伊人五月天久久综合
|
26uuu久久五月天
|
久久一区二区三区免费
|
亚洲AV无码久久精品成人
|
精品久久久久中文字幕日本
|
伊人久久大香线蕉影院95
|
久久久久久久免费视频
|
精品999久久久久久中文字幕
|
日韩欧美亚洲综合久久影院Ds
|
99久久777色
|
东方aⅴ免费观看久久av
|
www亚洲欲色成人久久精品
|
AV无码久久久久不卡蜜桃
|
久久99久久99小草精品免视看
|
欧美麻豆久久久久久中文
|
欧美亚洲国产精品久久蜜芽
|
无码伊人66久久大杳蕉网站谷歌
|
久久中文精品无码中文字幕
|
91精品国产综合久久精品
|
久久精品国产亚洲AV影院
|
久久久精品午夜免费不卡
|
一级女性全黄久久生活片免费
|
亚洲欧美成人久久综合中文网
|
久久国产精品久久国产精品
|
中文字幕无码免费久久
|
尹人香蕉久久99天天拍
|
日本久久久久久久久久
|
久久久久久久综合日本
|
激情久久久久久久久久
|
久久综合狠狠色综合伊人
|
久久综合给合久久国产免费
|
精品国产乱码久久久久久呢
|
亚洲国产视频久久
|
亚洲国产精品无码久久九九
|
久久国产视频99电影
|
久久精品亚洲福利
|
亚洲精品WWW久久久久久
|
欧美亚洲国产精品久久久久
|
中文字幕无码av激情不卡久久
|
一97日本道伊人久久综合影院
|