title: Array of Ofstream in c++
body: <p>I want 41 output files to use in my project to write text on them. first create a string array <code>list</code> to name those output files then I tried to define an array of ofstream objects and use <code>list</code> to name them, but I get this error that <code>'outfile' cannot be used as a function</code>. Below is my code:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;sstream&gt;
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  using namespace std ;
  int main ()
  {
    string list [41];
    int i=1;
    ofstream *outFile = new ofstream [41];
  
    for (i=1;i&lt;=41 ;i++)
    {
      stringstream sstm;
      sstm &lt;&lt; "subnode" &lt;&lt; i;
      list[i] = sstm.str();
    }
  
    for (i=0;i&lt;=41;i++)
      outFile[i] (list[i].c_str());
  
    i=1;
    for (i=1;i&lt;=41;i++)
      cout &lt;&lt; list[i] &lt;&lt; endl;
  
    return 0; 
  }
  </code></pre>