I am starting to learn c++ and have a simple question.
When i have std::vector
which schould hold some custom objects.
Is it better to create those object with the new
operator or should i just normally instantiate the objects and pass it to the vector? I am just wondering, because in Java
i do not need to care about this.
i.e. i am creating a bunch of objects in the main class. Then i pass these objects in a vector which is contained in another class Is it okay to instantiate the object on the stack? Or should i always do it with the new
operator (then i have to take care that the objects get deleted somewore). or is the simple answer: it depends on your program?
cheers