0

In C++ primer 4th 8.8.1 sections:

Why there is NO Copy or Assign for IO Objects?

ofstream out1, out2;  
out1 = out2;              // error: cannot assign stream objects  
ofstream print(ofstream); // error: can't initialize the ofstream parameter  
out2 = print(out2);       // error: cannot copy stream objects

Can anyone tell me the reason? Thanks a lot.

juanchopanza
  • 216,937
  • 30
  • 383
  • 461
fliu
  • 1

1 Answers1

0

The short answer is : it doesnt make sense to copy or reassign a C++ stream. The real question is: what are you trying to achieve exactly ?

quantdev
  • 23,038
  • 5
  • 54
  • 87