【发布时间】:2012-02-19 00:26:10
【问题描述】:
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,但还是不行。
当我#include <fstream> 而不是#include <iostream> 时,我在fstream.tcc 和basic_ios.tcc 中收到这些错误:
'operator=' is a private member of 'std::basic_streambuf<char>'
由于这是 fstream 库的一部分,显然我做的事情是错误的......
有人可以帮忙吗?
【问题讨论】:
-
你应该有
<fstream>而不是<iostream>operator=是真正的错误。输出窗口应该包含该错误消息的其余部分,包括复制Mapper对象的行号。 -
你需要显示导致第二个错误的代码。
标签: c++ compiler-errors fstream ifstream