策略模式testing1002.cpp
来源:互联网 发布:java怎么学 编辑:程序博客网 时间:2024/05/17 06:48
// 策略模式testing1002.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
using namespace std;
class Strategy
{
public:
virtual void show(){}
};
class StrategyA:public Strategy
{
public:
virtual void show(){cout<<"this is strategy A";}
};
class StrategyB:public Strategy
{
public:
virtual void show(){cout<<"this is strategy B";};
};
class Context
{
private:
Strategy& _strategy;
public:
Context(Strategy& strategy):_strategy(strategy)
{};
void show(){ _strategy.show(); };
};
int main()
{
Context* context=new Context(StrategyA());
context->show();
delete context;
return 0;
};
//
#include "stdafx.h"
#include<iostream>
using namespace std;
class Strategy
{
public:
virtual void show(){}
};
class StrategyA:public Strategy
{
public:
virtual void show(){cout<<"this is strategy A";}
};
class StrategyB:public Strategy
{
public:
virtual void show(){cout<<"this is strategy B";};
};
class Context
{
private:
Strategy& _strategy;
public:
Context(Strategy& strategy):_strategy(strategy)
{};
void show(){ _strategy.show(); };
};
int main()
{
Context* context=new Context(StrategyA());
context->show();
delete context;
return 0;
};
- 策略模式testing1002.cpp
- cpp的策略模式
- [c&cpp][memory] 内存对齐分配策略(含位域模式)
- [c&cpp][memory] 内存对齐分配策略(含位域模式)
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- eclipse创建user library
- StackWithMinTesting1007.cpp
- NSInvocation简单使用
- 如何使用免费敏捷工具放飞你的创造力?
- 最老程序员创业札记:全文检索、数据挖掘、推荐引擎应用27
- 策略模式testing1002.cpp
- 工厂模式testing0927.cpp
- linux下学习OpenGL
- 装饰模式testing0927.cpp
- iPhone_开发_基本术语_Serialization
- 结构之法 算法之道 博客地址 --- 对各种面试题的收集整理
- Android中Activity的生命周期
- 乔布斯时代结束
- VIM for windows + ctags + taglist + winmanager