codeArt

codeArt

策略模式c++表述备忘

#include <iostream>

using namespace std;

class Round1 {
public:
void Play() {
cout << "Round1::Play" << endl;
}
};

class Round2 {
public:
void Play() {
cout << "Round2::Play" << endl;
}
};

template <typename T>
class Strategy {
private:
T objT;
public:
void Play() {
objT.Play();
}
};

int main() {
Strategy<Round1> obj1;
Strategy<Round2> obj2;

obj1.Play();
obj2.Play();

return 0;
}

posted on 2010-08-27 20:43 codeArt 阅读(220) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2010年8月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234

导航

统计

常用链接

留言簿(1)

随笔分类

随笔档案

文章档案

编程与开源

搜索

最新评论

阅读排行榜

评论排行榜