A Singleton Class Example

template

class SharedSingleton
{
public:
static T& getInstance()
{
if(thePTRInstance.get() == NULL)
thePTRInstance.reset(new T);

return *thePTRInstance;

}

protected:
SharedSingleton(){};

private:
static std::auto_ptr< T > thePTRInstance;


}

No comments:

Post a Comment