惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

I
InfoQ
S
SegmentFault 最新的问题
T
Tailwind CSS Blog
美团技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
爱范儿
爱范儿
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI
量子位
博客园 - Franky
酷 壳 – CoolShell
酷 壳 – CoolShell
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
J
Java Code Geeks
The Cloudflare Blog
小众软件
小众软件
云风的 BLOG
云风的 BLOG
WordPress大学
WordPress大学
P
Proofpoint News Feed
Stack Overflow Blog
Stack Overflow Blog
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
B
Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog

博客园 - cosophy

ActiveX控件cab打包、Web嵌入、自动升级攻略 enable all verbs to application hosting on IIS 7.5 and using Asp.net 4.0 如何正确使用异常 ArcGIS 10 FlickrOnMap - A Silverlight Application Developed by Flickr Web API and ArcGIS Server API for Silverlight 关于Arcgis Server REST服务无法使用: Cannot acces http://localhost/arcgis/rest/services - cosophy Installing ArcGIS 9.3 On Microsoft Windows 7 SQL Server 2005 Express混合模式登录设置 List of REST Resources Enable SSL On IIS 7.0 Using Self-Signed Certificates 缅怀遥感地学之父、三院院士陈述彭先生 RSS Disabled: IE 7.0 could not read the RSS Feeds in the Feed List 关于地图投影与坐标系统 WCF:Configure svc MIME type on Vista IIS 7.0 ArcGIS Desktop 9.3 安装、破解 NSDTF-DEM格式数据 [ERR0134] Requested Service is not available 的解决方法 ERDAS 9.1 破解文件下载 修改ASP.NET成员提供程序,配置简单密码规则创建用户
C++单例模式
cosophy · 2012-04-23 · via 博客园 - cosophy

#ifndef _SINGLETON_H_ #define _SINGLETON_H_

//单件类

#include <memory>

using namespace std;

template <class T> class Singleton {

public:  static T* Instance()  {   if( 0 == _instance.get())   {    _instance.reset( new T);   }   return _instance.get();  }

private:  Singleton(void){}  /*  ~Singleton(void){};  Singleton(const Singleton&){};  Singleton & operator= (const Singleton &){};*/

 static auto_ptr<T> _instance; };

template <class T> auto_ptr<T> Singleton<T>::_instance;

//实现类T必须调用以下宏

#define DECLARE_SINGLETON_CLASS(type)\ friend class auto_ptr<type>;\ friend class Singleton<type>;

#endif

 REFENCENCE: http://blog.csdn.net/liuxialong/article/details/6764688