为什么会出现此ifstream错误? [英] Why am I getting this ifstream error?

查看:324
本文介绍了为什么会出现此ifstream错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

未定义模板'std :: basic_ifstream< char,std :: char_traits< char>>>'

Implicit instantiation of undefined template 'std::basic_ifstream<char,std::char_traits<char>>'

#ifndef MAPPER_H
#define MAPPER_H
#include <iostream>
#include <string>
#include <vector>
#include "KeyValue.h"
#include "Parser.h"

using namespace std;
class Mapper
{
public:
    Mapper(ifstream& infile);
    ~Mapper(void);
    void loadTokens();
    void showTokens();
    void map();
    void printMap();
    void printMap(string map_fileName);
private:
    ifstream inFile;  //<-- is where the error is happening
    vector<string> tokens;
    vector<KeyValue> map_output;
    Parser* parser;
};

#endif

我什至尝试放入 std :: ifstream 仍然不起作用。

I've even tried putting std::ifstream and it still doesn't work.

当我 #include< fstream> 而不是 #include&ioio> ,我在 fstream.tcc 中得到这些错误,并且 basic_ios.tcc

When I #include <fstream> instead of #include <iostream>, I get these errors in fstream.tcc and basic_ios.tcc:

'operator ='是'std的私有成员: :basic_streambuf< char>'

由于这是fstream库的一部分,显然我正在做的事情是错误的...

And since that's part of the fstream library, obviously something i'm doing is wrong...

有人能帮助吗?

推荐答案

您不见了

#include <fstream>

,您可能会将东西分配给 inFile 不允许。

and you probably assign somthing to inFile which is not allowed.

这篇关于为什么会出现此ifstream错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆