I have a class whose object must be created on the heap. Is there any better way of doing this other than this:
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();
};