[問題] 錯誤訊息請教 - error C2679

看板C_and_CPP (C/C++)作者 (藍影)時間15年前 (2010/07/13 16:05), 編輯推噓2(202)
留言4則, 3人參與, 最新討論串1/1
( *[1m *[m 為色碼,可以按 Ctrl+V 預覽會顯示的顏色 ) ( 未必需要依照此格式,文章條理清楚即可 ) 遇到的問題: (題意請描述清楚) error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable convers ion) fatal error C1903: unable to recover from previous error(s); stopping compilation Error executing cl.exe. 希望得到的正確結果: 程式跑出來的錯誤結果: 開發平台: (例: VC++ or gcc/g++ or Dev-C++, Windows or Linux) VC++ 有問題的code: (請善用置底文標色功能) #include<iostream> using namespace std; int main() { string s; while(cin >> s){ cout << "hello, "<< s << endl; } return 0; } 補充說明: 各位先進實在很抱歉 連我都覺得這個問題有點蠢 我用 VC6.0, 由於前一陣子都使用 <stdio.h>,<stdlib.h> 等 C library 最近換 C++ library 先寫測試程式時, 竟然發現連 complier 都沒辦法過!! ( 我於其它線上測試系統測試是可過的 ) 請問是否我語法或是設定哪有問題? 謝謝各位指教 -- 我期待 我等待 肩狹骨上的翅膀早些長出來 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 180.177.77.78

07/13 16:17, , 1F
加#include <string>看看
07/13 16:17, 1F

07/13 16:18, , 2F
同樓上
07/13 16:18, 2F

07/13 16:33, , 3F
謝謝解簽!! 感激不盡
07/13 16:33, 3F

07/13 17:27, , 4F
某些compiler可以是因為iostream偷偷include string
07/13 17:27, 4F
文章代碼(AID): #1CF1v8jD (C_and_CPP)
文章代碼(AID): #1CF1v8jD (C_and_CPP)