Why am I getting this ifstream error?

匿名 (未验证) 提交于 2019-12-03 02:54:01

问题:

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 

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

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

'operator=' is a private member of 'std::basic_streambuf<char>'

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

Anyone able to help?

回答1:

You're missing

#include <fstream> 

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!