suppose I have the following class:
class MyInteger { private: int n_; public: MyInteger(int n) : n_(n) {}; // MORE STUFF };
And supp
Besides all answers which answered the question very well, in a case that your class MyInteger is not copy-constructible, you could use this trick : instead of creating vector< MyInteger>, you could create vector< shared_ptr< MyInteger > >
vector< MyInteger>
vector< shared_ptr< MyInteger > >