Item 3: Make copying cheap and correct for objects in containers
This item is simple.
Whether you put an object into a container, get an object from it or move objects in a container, the copying thing happens.
The slicing problem should be avoided, this is an easy work.
You can also store pointers to objects instead of objects in the container, so as to make the copying correct and efficient.But in this case you have to deal with memory management yourself, memory leak is prone to happen.
Whether you put an object into a container, get an object from it or move objects in a container, the copying thing happens.
The slicing problem should be avoided, this is an easy work.
You can also store pointers to objects instead of objects in the container, so as to make the copying correct and efficient.But in this case you have to deal with memory management yourself, memory leak is prone to happen.