title: vector of ofstream pointers
body: <p>Here is my problem, I need to create X number of files and write to them depending on different factos, my solution was to create a vector of ofstream pointers like this</p>
  
  <pre><code>#include &lt;boost/algorithm/string.hpp&gt;
  #include &lt;vector&gt;
  #include&lt;string&gt;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  vector&lt;ofstream*&gt; files;
  files.resize(SplitVec.size()-4);
            for(i=0;i&lt;SplitVec.size()-4;i++)
            {
                line="/Users/jorge/Desktop/testing/strain_"+lexical_cast&lt;string&gt;(i);
                cout&lt;&lt;"ine"&lt;&lt;endl;
                files[i]=new ofstream(line.c_str());
            }
  </code></pre>
  
  <p>Until this part it creates the files great, and later in the program I write to them, which is also great, my problem is when I want to close the objects, if I use:</p>
  
  <pre><code>for(i=0;i&lt;SplitVec.size()-4;i++)
            {
                *files[i].close();
            }
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>In file included from main.cpp:14:./methyl.h:298: error: request for member 'close' in 'files. std::vector&lt;_Tp, _Alloc&gt;::operator[] [with _Tp = std::ofstream*, _Alloc = std::allocator&lt;std::ofstream*&gt;](1ul)', which is of non-class type 'std::ofstream*'
  </code></pre>
  
  <p>So, I have a question, first, why cant I call close, its a pointer to an ofstream, so with *files[i], I would have imagined I could close it, second, if I don't close it, the program works ok, but im almost sure that this is a bad practice and don't want to be a lazy or crappy programer, Ive looked as much as I could, but Ive failed finding an answer.
  Thank you!!!</p>