作者typecommand (:))
看板Programming
标题[问题] C++编译出现错误讯息
时间Fri Apr 18 19:49:08 2008
※ [本文转录自 C_and_CPP 看板]
作者: typecommand (:)) 看板: C_and_CPP
标题: [问题] C++编译出现错误讯息
时间: Fri Apr 18 19:48:47 2008
已自行上google找答案,有找到可能的解答,但还是看不懂,
所以只好上来请教高手
http://www.cs.ucla.edu/~shinnerl/cs31/x/simpleIO/noStreamCopy.cpp
这是我的部份程式码
(simstream.h)
class SimS {
public:
SimS (ostream &s);
~SimS (void);
private:
ofstream fp;
ostream stream;
friend class SimStream;
};
(simstream.cpp)
SimS::SimS (ostream &s) {
rc = 1;
stream = s; <------这行会出错,错误讯息如下
is_opened = 0;
}
simstream.cpp: In method `ostream &ostream::operator= (ostream &)':
/usr/include/g++-3/streambuf.h:127: `ios &ios::operator= (ios &)' is private
simstream.cpp:19: within this context
恳请高手能给我一点方向,因为我这问题卡很久了,先谢谢了。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.136.149.183
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.136.149.183
1F:推 sunneo:simstream.c220.132.228.138 04/18 20:08
2F:→ sunneo:改副档名为cpp吧220.132.228.138 04/18 20:08
3F:→ sunneo:啊. 因为他不允许你使用operator=220.132.228.138 04/18 20:10
※ 编辑: typecommand 来自: 140.136.149.183 (04/18 20:22)
※ 编辑: typecommand 来自: 140.136.149.183 (04/18 20:23)
4F:→ typecommand:请教1F大大有什麽方法可解吗?谢谢140.136.149.183 04/18 20:23
5F:推 sunneo:让你的member也是reference220.132.228.138 04/18 20:25
6F:→ sunneo:用initialize list初始化ostream220.132.228.138 04/18 20:26
7F:→ netsphere:二楼讲了阿 XD 改副档名为cpp吧 125.224.165.28 04/18 20:26
8F:→ typecommand:回覆楼上,我改成cpp问题依旧,谢谢140.136.149.183 04/18 21:30
9F:→ typecommand:感谢s大提供的建议,我马上试看看140.136.149.183 04/18 21:53