博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
用32行代码表示16个设计模式 (转)
阅读量:2501 次
发布时间:2019-05-11

本文共 859 字,大约阅读时间需要 2 分钟。

用32行代码表示16个设计模式 (转)[@more@]

为了演示以下16个,用了下面32行代码。

iterator,adapter,interpreter,,
state,visitor,command,bridge,
chain of responsibility,composite,
flyweight,strategy,decorator,
mediator,memento,observer
void main(){
for(i=0;i<2;i++){
  if (i==0){Actor getUpActor=new GetUpActor();
  getUpActor.Action();
  delete getUpActor;}
  else if(i==1){Actor supperActor=new SupperActor();
  supperActor.Action();
  delete supperActor;
}
}
class Actor(){
public:
virtual void Action()=0;
protected:
Actor();
};
class GetUpActor():public Actor{
public:
virtual void Action();
  GetUpActor();
};
void GetUpActor:Action{
cout<}
class SupperActor():public Actor{
public:
virtual void Action();
  SupperActor();
};
void SupperActor():Action{
cout<}

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10748419/viewspace-1008735/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10748419/viewspace-1008735/

你可能感兴趣的文章
openstack报错解决三
查看>>
乙未年年终总结
查看>>
子网掩码
查看>>
第一天上班没精神
查看>>
启动eclipse报错:Failed to load the JNI shared library
查看>>
eclipse安装插件的两种方式在线和离线
查看>>
linux下源的相关笔记(suse)
查看>>
linux系统分区文件系统划分札记
查看>>
Linux(SUSE 12)安装Tomcat
查看>>
Linux(SUSE 12)安装jboss4并实现远程访问
查看>>
Neutron在给虚拟机分配网络时,底层是如何实现的?
查看>>
netfilter/iptables全攻略
查看>>
Overlay之VXLAN架构
查看>>
Eclipse : An error occurred while filtering resources(Maven错误提示)
查看>>
在eclipse上用tomcat部署项目404解决方案
查看>>
web.xml 配置中classpath: 与classpath*:的区别
查看>>
suse如何修改ssh端口为2222?
查看>>
详细理解“>/dev/null 2>&1”
查看>>
suse如何创建定时任务?
查看>>
suse搭建ftp服务器方法
查看>>