title: cpp compiler could not generate operator = for class fstreambase, istream and ostream
body: <p>I am trying to concatenate the contents of file1 and file2 into file3 using operator overloading in c++, but it is giving me 3 errors as mentioned
  below :</p>
  <p><em>Error : compiler could not generate operator= for class 'fstreambase'</em></p>
  <p><em>Error : compiler could not generate operator= for class 'istream'</em></p>
  <p><em>Error : compiler could not generate operator= for class 'ostream'</em></p>
  <p><strong>Here is my code :</strong></p>
  <pre><code>#include&lt;iostream.h&gt;
  #include&lt;conio.h&gt;
  #include&lt;string.h&gt;
  #include&lt;fstream.h&gt;
  
  class myfile
  {
      fstream file;
      char filename[10],data[50];
      public:
          myfile()
          {
              //cout&lt;&lt;&quot;File3 created\n&quot;;
          }
  
          myfile(char *fn)
          {
              strcpy(filename,fn);
          }
  
          void accept()
          {
              cout&lt;&lt;&quot;\nEnter data for file &quot;&lt;&lt;filename&lt;&lt;&quot; :\n&quot;;
              cin.getline(data,50);
              file.open(filename,ios::out);
              file&lt;&lt;data;
              file.close();
          }
  
          void display()
          {
              char ch;
              cout&lt;&lt;&quot;Contents of &quot;&lt;&lt;filename&lt;&lt;&quot; :\n&quot;;
              file.open(filename,ios::in);
              while(file)
              {
                  file.get(ch);
                  cout&lt;&lt;ch;
              }
              file.close();
              cout&lt;&lt;endl;
          }
  
          myfile operator+(myfile &amp;f2)
          {
              myfile f3(&quot;file3.txt&quot;);
              fstream file1,file2,file3;
              file1.open(this-&gt;filename,ios::in);
              file2.open(f2.filename,ios::in);
              file3.open(f3.filename,ios::out);
              char ch;
              while(file1)
              {
                  file1.get(ch);
                  file3&lt;&lt;ch;
              }
              return f3;
          }
  };
  
  void main()
  {
      clrscr();
      myfile f1(&quot;file1.txt&quot;);
      myfile f2(&quot;file2.txt&quot;);
      myfile f3(&quot;file3.txt&quot;);
      f1.accept();
      f1.display();
  
      f2.accept();
      f2.display();
  
      f3=f1+f2;            //Those 3 errors generates on this line
      f3.display();
      getch();
  }
  </code></pre>
  <p><strong>Ps: The code is not yet complete(inside overloading function) and I'm using TurboC3 compiler</strong></p>
  <p><a href="https://i.stack.imgur.com/dn8rl.png" rel="nofollow noreferrer">This is the question btw</a></p>
  <p>What am I doing wrong here? Please help. Thank you.</p>