Hi,
I'm creating some objects which come from various inherited classes (with a single base class).
After the objects have been created, a want to save the object's values to a text file, bit like a database.
Up until now I have always used this type of constructor:
Code:
foo node(arg1, arg2);//old constructor for the stack
I have come to learn that this creates on object on the stack.
But after reading how references give more functionality, I think they would be better for my requirements.
I was hoping for some general advice on whether this would be the right decision.
I have managed to create a pointer to the objects, using this:
Code:
foo *ptr = new foo(arg1, arg2);
Which I believe creates the object in the heap and the pointer on the stack.
Do you think I should use references?
I have a vector which which I need to use to store either pointers or references to the mixed class objects.
Right now it looks like this:
Code:
vector <foo*> vectorname;
So basically I'm wondering if I should use references, or stick with pointers?
Many thanks for any advice!