
设计模式
PinKrystal
哈哈哈
展开
-
单例模式及C++实现代码
单例模式 单例模式,可以说设计模式中最常应用的一种模式了,据说也是面试官最喜欢的题目。但是如果没有学过设计模式的人,可能不会想到要去应用单例模式,面对单例模式适用的情况,可能会优先考虑使用全局或者静态变量的方式,这样比较简单,也是没学过设计模式的人所能想到的最简单的方式了。 一般情况下,我们建立的一些类是属于工具性质的,基本不用存储太多的跟自身有关的数据,在这种情况下,每次都去new一转载 2016-03-11 22:15:33 · 453 阅读 · 0 评论 -
C++ 单例模式实现代码
#pragma once class singleton { public: //static int a; static singleton * getinstance() { if (!instance) { instance = new singleton(); } return instance; } static void release() { if原创 2016-03-12 14:48:48 · 323 阅读 · 0 评论