我有一个类,其对象必须在堆上创建。除此之外是否还有其他更好的方法:控制对象创建
class A
{
public:
static A* createInstance(); //Allocate using new and return
static void deleteInstance(A*); //Free the memory using delete
private:
//Constructor and destructor are private so that the object can not be created on stack
A();
~A();
};