S
SpreadTooThin
if I build a list of objects does push_back end up making a copy of
the object itself?
I have a problem.. when the list is destroyed...
as an example of what my code does....
std::list<myObject> myListOfObjects;
myObject obj;
for i=0; i < n; ++i
{
obj.modifySomeProperty;
myList.push_back(obj);
}
When the function returns the list is destroyed by going out of
scope.. and of course so is obj.
First off ... Maybe I should have created a new instance of myObject
on each iteration of the loop or perhaps using the same one over and
over again is OK.... (as long as push_back is making a copy of the
object.)
Suggestions?
the object itself?
I have a problem.. when the list is destroyed...
as an example of what my code does....
std::list<myObject> myListOfObjects;
myObject obj;
for i=0; i < n; ++i
{
obj.modifySomeProperty;
myList.push_back(obj);
}
When the function returns the list is destroyed by going out of
scope.. and of course so is obj.
First off ... Maybe I should have created a new instance of myObject
on each iteration of the loop or perhaps using the same one over and
over again is OK.... (as long as push_back is making a copy of the
object.)
Suggestions?