强弱引用
singleton模式的宏定义
factory模式
单例类的使用
#include "boost/shared_ptr.hpp"
#include "boost/make_shared.hpp"
#define DECLARE_SINGLETON(ClassName); \
public: \
static boost::shared_ptr<ClassName>& Instance(void); \
private: \
static boost::shared_ptr<ClassName> instance_; \
public: \
#define DEFINE_SINGLETON(ClassName) \
boost::shared_ptr<ClassName> ClassName::instance_; \
boost::shared_ptr<ClassName>& ClassName::Instance(void) \
{
singleton模式的宏定义
factory模式
单例类的使用
#include "boost/shared_ptr.hpp"
#include "boost/make_shared.hpp"
#define DECLARE_SINGLETON(ClassName); \
public: \
static boost::shared_ptr<ClassName>& Instance(void); \
private: \
static boost::shared_ptr<ClassName> instance_; \
public: \
#define DEFINE_SINGLETON(ClassName) \
boost::shared_ptr<ClassName> ClassName::instance_; \
boost::shared_ptr<ClassName>& ClassName::Instance(void) \
{