Connecting Tech Pros Worldwide Forums | Help | Site Map

Why there is NO Copy or Assign for IO Objects?

Newbie
 
Join Date: Dec 2007
Posts: 7
#1: Dec 21 '07
Expand|Select|Wrap|Line Numbers
  1. ofstream out1, out2;
  2.     out1 = out2;   // error: cannot assign stream objects
  3.     // print function: parameter is copied
  4.     ofstream print(ofstream);
  5.     out2 = print(out2);  // error: cannot copy stream objects
Why there is NO Copy or Assign for IO Objects? Can anyone tell me the reason? Thanks!

RRick's Avatar
Expert
 
Join Date: Feb 2007
Posts: 430
#2: Dec 22 '07

re: Why there is NO Copy or Assign for IO Objects?


Probably, because of what is inside the object.

BTW: This sounds suspiciously like an exam question.

Take a look at the state of an io object and you'll find flags for eof, fail, bad, etc. What would happen to the flags in one object if they changed in another copy of the object.
Reply


Similar C / C++ bytes