【问题标题】:Why C++ is NO Copy or Assign for IO Objects? [duplicate]为什么 C++ 不能复制或分配 IO 对象? [复制]
【发布时间】:2014-06-02 13:34:47
【问题描述】:

在 C++ 入门第 4 节 8.8.1 部分中:

为什么 IO 对象没有复制或分配?

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

谁能告诉我原因?非常感谢。

【问题讨论】:

    标签: c++ io iostream istream ostream


    【解决方案1】:

    简短的回答是:复制或重新分配 C++ 流没有意义。 真正的问题是:您到底想达到什么目的?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-16
      • 2018-10-29
      • 1970-01-01
      • 2016-02-09
      • 1970-01-01
      • 2015-10-08
      • 1970-01-01
      相关资源
      最近更新 更多