Is this a correct implementation of singleton C++?
- by Kamal
class A{
static boost::shared_ptr<A> getInstance(){
if(pA==NULL){
pA = new A();
}
return boost::shared_ptr(pA);
}
//destructor
~A(){
delete pA;
pA=NULL;
}
private:
A(){
//some initialization code
}
//private assigment and copy constructors
A(A const& copy); // Not Implemented
A& operator=(A const& copy); // Not Implemented
static A* pA;
};
A* A::pA = NULL;