But, to put my Devil's Advocate hat on a moment: the environment could be GCed and new could be overridden to return a GCed pointer, as opposed to a naked pointer. (There are lots of good GCs for C++ -- see, e.g., http://www.hboehm.info/gc/)
One of the great things about C++ is how thoroughly you can customize the system using operator overloading. One of the big drawbacks about C++ is that without knowing the precise environment in which the code is operating, you really don't know what 'new' does. Or any other operator, for that matter. :)
Most of the smartpointers in the modern C++ standard weren't official until TR1 in 2003; even then, a lot of compilers took a long time to catch up. Prior to 2003, the only smartpointer in the C++ standard was std::auto_ptr, which had some really unpleasant semantics.
There were two basic choices: go with a smartpointer library like Boost or Loki, or go with the Boehm-Demers-Weiser GC. The GC route was pretty easy and minimal pain, while Boost and Loki were moving targets. A lot of places went with the more stable BDWGC instead.
Because you avoid having to think about where to put the object while also not eating the cost of copying it if you guess wrong.
The lifetime of a heap object is whatever you define the lifetime to be (which thanks to GC is very flexible) the lifetime of a stack object has an absolute maximum.
> The point is that they don’t understand C++ object model. Objects live on the stack except explicitly stated.
So, why did managed language designers decide to use heap allocation for reference type objects?
About that vector2d class: it took me some time to get it, but now I can't unsee that memory leak going on there.