title: ofstream variable in name
body: <p>I'm trying to create an ofstream and then write values from an array into it.</p>
  
  <pre><code>void Graph::toFile(char* filename)
  {
      ofstream outfile(filename.c_str()+"_new.txt");
      for(int i = 0; i &lt; noOfVertices; i++)
          outfile &lt;&lt; graphPartition[i] &lt;&lt; endl;
      outfile.close();
  }
  </code></pre>
  
  <p>My main problem is, that I want the output file to be named <code>filename+"new.txt"</code>. However, there is something wrong with my approach, because i keep getting an error <code>expression must have class type</code>.</p>
  
  <p>I'm really sorry, if this question is a duplicate, I haven't found an satisfying solution.</p>