title: C++ - Object destructed when out of scope and in vector
body: <p>Why is the destructor of an object called when it goes out of scope and when it is in a vector ?
  For example :</p>
  
  <pre><code>std::vector&lt;Foo&gt; vec;
  for (i=10; i&lt;10; i++)
  {
     Foo object(i);
     vec.push_back(object);
  } 
  </code></pre>
  
  <p>Is the destructor of object called because it goes each time out of scope? Can I make it work without pointers or shared_pointers? </p>