包含 header 后的 Stringstream 编译错误
Stringstream compile error after including header
我正在尝试使用字符串流读取字符串并将其转换为各种其他数据类型。但是,我不断收到错误 "Incomplete data type not allowed."
我对这个错误的研究恰好找到了两个修复方法:确保包含 header,并使用 std::stringstream 而不是 stringstream。这些修复都没有帮助我。有什么想法吗?
#include <sstream>
bool Arena::addFighter(string info){
std::stringstream ss;
ss.getline(info);
...
}
编辑:getline() 不是问题所在。当我尝试声明 ss object.
时代码抛出错误
改变这个
ss.getline(info);
至此
getline(ss, info);
检查 this question for how to use getline()
. Also check the ref 后再询问。 :)
我得到的错误是这样的:
error: no matching function for call to ‘std::basic_stringstream<char>::getline(std::string&)’
ss.getline(info);
如果您没有使用命名空间标准,那么您应该传递一个 std::string
作为参数,而不仅仅是一个 string
.
我正在尝试使用字符串流读取字符串并将其转换为各种其他数据类型。但是,我不断收到错误 "Incomplete data type not allowed."
我对这个错误的研究恰好找到了两个修复方法:确保包含 header,并使用 std::stringstream 而不是 stringstream。这些修复都没有帮助我。有什么想法吗?
#include <sstream>
bool Arena::addFighter(string info){
std::stringstream ss;
ss.getline(info);
...
}
编辑:getline() 不是问题所在。当我尝试声明 ss object.
时代码抛出错误改变这个
ss.getline(info);
至此
getline(ss, info);
检查 this question for how to use getline()
. Also check the ref 后再询问。 :)
我得到的错误是这样的:
error: no matching function for call to ‘std::basic_stringstream<char>::getline(std::string&)’
ss.getline(info);
如果您没有使用命名空间标准,那么您应该传递一个 std::string
作为参数,而不仅仅是一个 string
.