The functionality can be achieved by making the constructor private. You will still need a static function to get the heap allocated handle. This is how i usually do it (the same behavior you asked for)
P.S. this is not complete code, just half baked solution to show you the direction.
#include <iostream>
using namespace std;
class A
{
private:
A()
{
}
public:
static A* CreateAndGetInstancePointer()
{
return new A();
}
int test()
{
return 2;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
A *pa = A::CreateAndGetInstancePointer();
cout << pa->test();
return 0;
}
</iostream>