當我運行此程序我得到在管線s<<"\""<<string<<"\""
下面提到錯誤:誤差在該C++程序
#include <string>
#include <iostream>
#include <sstream>
#include <cstdlib>
using namespace std;
string str="abc";
stringstream s;
s<<"\""<<string<<"\"";
cout<<(s.str().c_str());
錯誤:預期構造,析構函數,或類型轉換之前「< <」令牌 彙編終止,因爲重大錯誤。
http://codepad.org/KuyMQg3x,這裏是在線錯誤代碼。
你是不是指'str'而不是'string'? – chris
你把字符串作爲變量名(太晚:) – nico
同樣的錯誤,更正後。 – rajat