I'm learning my way through std vectores and c++ and can't understand one thing: how do I write code that uses the automatic way of handling memory (constructores & destructores)?
What I want to do (inside a function that returns a pointer to the created object):
- Create one Item with the atribute name set to "ball"
- Put it inside a global vector
- return the pointer to the created Item.
This sample code is the best idea of how to use I came up with. I'm pretty sure I'm missing something.
bag.back().name = "ball";
Is this really the way handle the references vs objects?