【发布时间】:2014-02-05 09:21:05
【问题描述】:
我是 C++ 新手,我正在尝试启动并运行一个简单的程序。
我在 Windows 系统上使用 Eclipse IDE(C++ 版本)。
我正在尝试连接一个输出语句,它将结合数字和字符串。
我知道在 Java 中,这是通过 System.out.println() 方法自动完成的。
我能够研究的是在 C++ 中实现这一点的一个好方法是使用字符串流方法。
#include <iostream>
#include <string>
#include "Person.h"
...
string simpleOutput(){
stringstream ss;
int a = 50; // for testing purposes
int b = 60;
string temp = "Random";
ss << a << b << temp;
return string output = ss.str();
}
当我尝试编译此代码时,得到以下信息:“方法“str”无法解析。
我还没有在任何网页上找到解决方案。 吨 谢谢!
【问题讨论】:
-
@Psypher 我完全不确定你指的是什么。 OP确实使用
stringstream -
@IvayloStrandjev 也许是
stringsteam(缺少r)? -
我看到的是“stringsteam”,而不是“stringstream”(或者我读到 SO 太晚了)。
-
@Angew,WhozCraig 对 :) 抱歉。我仍然相信这只是一个错字。
-
@IvayloStrandjev 我也是。
标签: c++ string output stringstream