为什么我会收到此 ifstream 错误?

发布于 2024-12-28 20:33:08 字数 1046 浏览 3 评论 0 原文

未定义模板'std::basic_ifstream>'的隐式实例化


#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 而不是 #include 时,我在 fstream.tcc 中收到这些错误basic_ios.tcc

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

并且由于它是fstream库的一部分,显然我做的事情是错误的...

有人能帮忙吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

路还长,别太狂 2025-01-04 20:33:08

您丢失了

#include <fstream>

,并且您可能将一些不允许的内容分配给 inFile

You're missing

#include <fstream>

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文