単一クラステンプレートの解析に関する問題
2966 ワード
, , , 。 , , 。
:
( CGarbo) 。 sGarbo. c++ , , , CGarbo 。 , , , sGarbo , , , vs ,
template< class T > PlantSingleton::CGarbo PlantSingleton::sGarbo;
, PlantSingleton typename, , , :
template< class T > typename PlantSingleton::CGarbo PlantSingleton::sGarbo;
, , sGarbo , , sGarbo , , 。 , GetInstance sGarbo, , , , , , 。 , , 。 , , , 。 , , 。
, , , , , , , , 。
, 。 《 》, , , ,
#ifndef __SINGLETN_H__
#define __SINGLETN_H__
#include "cocos2d.h"
template< class T >
class Singleton
{
public:
class CGarbo // CSingleton
{
public:
~CGarbo()
{
if( PlantSingleton::spInstance )
{
delete PlantSingleton::spInstance;
PlantSingleton::spInstance = NULL;
}
}
};
private:
public:
static T* spInstance;
public:
~Singleton( )
{
}
static T* GetInstance( )
{
if ( spInstance == 0 )
spInstance = new T;
return spInstance;
}
protected:
// , ,
static CGarbo sGarbo;
};
template< class T > typename Singleton::CGarbo PlantSingleton::sGarbo;
template< class T > T* Singleton::spInstance = 0;
#endif // ___SINGLETN_H__
, , , , destroy(); , , destroy(); ,