When to use “new” and when not to, in C++? [duplicate]
You should use new when you wish an object to remain in existence until you delete it. If you do not use new then the object will be destroyed when it goes out of scope. Some examples of this are: void foo() { Point p = Point(0,0); } // p is now destroyed. for (…) … Read more