小编Axm*_*ill的帖子

在头文件中使用未声明的标识符(Clang)

我正在创建一个函数来读取位于IO.cpp文件中的文件内容:

#include "IO.h"
#include <iostream>
#include <fstream>
IO::IO()
{
    //ctor
}

void IO::readFile(std::string fileName)
{
    std::ofstream inputFile;
    inputFile.open(FileName);
    inputFile >> fileName.toStdString;
    inputFile.close();
    std::cout << fileName;
}
Run Code Online (Sandbox Code Playgroud)

使用头文件IO.h:

#ifndef IO_H
#define IO_H


class IO
{
    public:
        IO();
        void readFile(std::string inputFile);
    protected:
    private:
};

#endif // IO_H
Run Code Online (Sandbox Code Playgroud)

但是我从Clang那里得到了一个错误

include/IO.h | 9 | error:使用未声明的标识符'std'|

我无法弄清楚如何解决它.

c++ function shared-libraries clang header-files

12
推荐指数
1
解决办法
3万
查看次数

标签 统计

c++ ×1

clang ×1

function ×1

header-files ×1

shared-libraries ×1