A
Anjo Gasa
Let's say I have:
std::vector<Object> rgObjects;
rgObjects itself is declared as a local variable and hence on the
stack. But what about as I add elements to rgObjects:
Object newObject( 3, 4 );
rgObjects.push_back( newObject );
newObject itself isn't placed on the vector, rather the copy
constructor is called, and an object copied with its values is placed
on the vector. Does this new instance of Object reside on the stack or
the heap.
Anjo
std::vector<Object> rgObjects;
rgObjects itself is declared as a local variable and hence on the
stack. But what about as I add elements to rgObjects:
Object newObject( 3, 4 );
rgObjects.push_back( newObject );
newObject itself isn't placed on the vector, rather the copy
constructor is called, and an object copied with its values is placed
on the vector. Does this new instance of Object reside on the stack or
the heap.
Anjo