DaveP wrote:
...
By doing it this way not only do you need to worry about deallocation during a stack unwind or the messy business of supporting exception throwing on a constructor but you have nicely introduced yourself to the concepts of "Homes" and "Factories" for object instances so beloved of Distributed OO.
Also, factories are very well worth a look because of a very cool feature that everbody getting into OOP craves at some point - the 'virtual' constructor. In reality, a virtual constructor is impossible since the compiler must know the exact object to be instansiated.
However, A factory can take a pointer to an existing polymorphic object and return a pointer to a new instance of the same class (usually via some virtual function magic).
There are several ways of doing this, I found that the method described in Bjaarne Stroustrup's 'The C++ Programming Language' 3rd Ed. works for me...