什么两码的差异吹:左操作数的类型 '的std :: stringstream的(__cdecl *)(的std :: string)'
char buf[2048];
stringstream in(string(buf));
int tmpInt;
while ((in >> tmpInt)) { // wrong, error C2296: '>>' : illegal, left operand has type 'std::stringstream (__cdecl *)(std::string)'
}
和
char buf[2048];
string tmpStr(buf);
stringstream in(tmpStr);
while ((in >> tmpInt)) { // right
}
我觉得他们做的同样的事情:都使用字符串来构造一个stringstream对象。无论临时对象或一个真正的对象,我们将调用stringstream的字符串拷贝构造函数(只复制BUF内容)
IDE:vs2010
那么,究竟这两种方式有什么不同?或者stringstream实现方式。
谢谢。
这是最让人头疼的解析。 – chris