Tec*_*upe 12 c++ syntax sstream
我是c ++的新手,请帮我弄清楚这有什么问题
string c;
stringstream out; //aggregate 'std::stringstream out' has incomplete type and cannot be //defined
out << it->second;
out << end1;//'end1' was not declared in this scope
c = out.str();
Run Code Online (Sandbox Code Playgroud)
Aln*_*tak 24
你是否:
#include <sstream>
Run Code Online (Sandbox Code Playgroud)
此外,倒数第二行应该是endl(nb:小写L)而不是end1(第一行).
下面的代码在MacOS X上与G ++ 4.2.1一起编译并正常工作
#include <iostream>
#include <sstream>
int main() {
std::stringstream out;
out << "foo" << std::endl;
std::string c = out.str();
std::cout << c;
}
Run Code Online (Sandbox Code Playgroud)
#include <sstream>在我的系统上省略与第一个错误完全相同的错误.
它是小写L而不是1:
out << endl;
Run Code Online (Sandbox Code Playgroud)
我认为@Bo是对的,(对不起,谢谢)改成它 std::stringstream out;
您似乎缺少 stringstream 的包含。最重要的是你有一个错字
out << end1;
Run Code Online (Sandbox Code Playgroud)
应该读
out << endl;
Run Code Online (Sandbox Code Playgroud)
l代替1。