title: Deleting vector of pointers
body: <p>I need to create pointers of instances of a class, and the program do not know at compilation time how many pointers I will create.
  For deletion, I was considering storing the pointers in a vector, and then deleting them one by one. 
  Would the use of smart pointers a cleaner way to go ?
  And if one does not want to use smart pointers, would this use of vector be considered clean ?</p>
  
  <p>Minimum code:</p>
  
  <pre><code>#include &lt;vector&gt;
  using namespace std;
  
  class Foo {
  public:
      Foo();
  };
  Foo::Foo(){}
  void createFooVector(int nb, std::vector&lt;Foo*&gt; &amp;v){
      for(int i=0;i&lt;nb;i++){
          Foo* f = new Foo();
          v.push_back(f);
      }
  }
  int main(int argc, char *argv[]){
      std::vector&lt;Foo*&gt; v;
      createFooVector(5,v); 
      while (!v.empty()){
          Foo* f = v.back();
          v.pop_back();
          delete f;
      }
  }
  </code></pre>