作者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
推 sunneo:simstream.c220.132.228.138 04/18 20:08
→ sunneo:改副檔名為cpp吧220.132.228.138 04/18 20:08
→ 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)
→ typecommand:請教1F大大有什麼方法可解嗎?謝謝140.136.149.183 04/18 20:23
推 sunneo:讓你的member也是reference220.132.228.138 04/18 20:25
→ sunneo:用initialize list初始化ostream220.132.228.138 04/18 20:26
→ netsphere:二樓講了阿 XD 改副檔名為cpp吧 125.224.165.28 04/18 20:26
→ typecommand:回覆樓上,我改成cpp問題依舊,謝謝140.136.149.183 04/18 21:30
→ typecommand:感謝s大提供的建議,我馬上試看看140.136.149.183 04/18 21:53