当我尝试使用第一种形式声明iss时,g ++给我“错误:在'iss >> s'中不匹配'operator >>'。但是,这两个不同的声明不是做同样的事情吗?为什么不编译?
#include <iostream>
#include <sstream>
#include <string>
int main() {
const char *buf = "hello world";
std::string ss(buf);
//std::istringstream iss(std::string(buf)); // this doesn't work
std::istringstream iss(ss); // but this does
std::string s;
iss >> s;
}
不,他在std命名空间中的前缀都是前缀。 – 2009-12-06 03:31:27
好的,我很抱歉!如果我错了,你不需要在岛上投票,我犯了一个错误,每个人都这样做。给一个人休息一下! – Jaba 2009-12-15 13:48:55
这不是一个个人的仇恨 - 它只是一个指标,表明你的回答是错误的,这是投票的一部分。 – 2009-12-15 20:51:26