[問題] ifstream問題
再寫openDofile的時候
_dofile = new ifstream(dof.c_str);
然後要用_dofile呼叫她的member function的時候,像是
_dofile.eof() 或是 _dofile.close()
都會compile錯誤:request member for 'close' ...省略...'_dofile', which is
non_class type "std::ifstream"
但是如果改成這樣呼叫:_dofile->eof(), 就可以了耶
為什麼會這樣啊??
網路和書的參考資料都是_dofile.eof()呼叫的
_dofile是pointer??
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.245.82
推
11/03 04:25, , 1F
11/03 04:25, 1F
→
11/03 04:25, , 2F
11/03 04:25, 2F
所以第一行應該寫成ifstream * _dofile = new ifstream(dof.c_str); 嗎?
還是說_dofile = new ifstream(dof.c_str);就已經讓_dofile 的type是ifstream *了?
※ 編輯: meanid 來自: 140.112.245.82 (11/03 04:34)
推
11/03 05:04, , 3F
11/03 05:04, 3F
推
11/03 06:40, , 4F
11/03 06:40, 4F
推
11/03 08:13, , 5F
11/03 08:13, 5F