Coming from Java, I have a tendency to use the new
keyword all the time in C++, but isn't this dangerous? I know about heap allocation and whatnot, but when in C++, is new
actually necessary?
I guess my question is how do I initialize an object without the new keyword?
class Foo {
int bar;
}
Given this class, this is instantiating it with the new keyword:
Foo aFoo = new Foo;
Is this the correct way to instantiate the Foo object without new?
Foo aFoo = Foo;