令牌生成器中的C ++错误``变量'std :: stringstream mystream'具有初始化程序但类型不完整''

Oie*_*lus 2 c++ tokenize c++11

我是c ++的新手,正在尝试从带有数字的文件中读取行,将行标记化为字符串数组,并将这些数组项转换为双精度数字。但是在标记化的过程中,我得到这个错误``变量'std :: stringstream mystream'具有初始化但类型不完整''。我看过其他人的建议,我想不使用boost来做,其余的代码看起来很像我的,但是由于某种原因我得到了这个错误。这是代码。

#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <iostream>
#include <fstream>

using namespace std;

int main ()
{
    vector<string> tokens;
    string phrase="sdfs sdfs trt we rw";
    stringstream mystream (phrase);
    string temp;

    while(getline(mystream,temp,' ')){
        tokens.push_back(temp);
    }
}
Run Code Online (Sandbox Code Playgroud)

得到有关此问题的反馈真是太好了。提前致谢。

sto*_*ist 6

我想你忘了

#include <sstream>
Run Code Online (Sandbox Code Playgroud)

在标题中。