如何使用operator>>
從std::istream
讀取?如何從std :: istream(使用操作符>>)讀取?
我試過如下:
void foo(const std::istream& in) {
std::string tmp;
while(in >> tmp) {
std::cout << tmp;
}
}
但它給出了一個錯誤:
error: no match for 'operator>>' in 'in >> tmp'
的istream的不應該是一個開始常量。 istream對象的狀態將需要改變,因爲你將數據從數據中提取出來。 – 2009-08-19 22:39:53