隐式实例化未定义模板&#st; :: __ 1 :: basic_ifstream

时间:2018-02-24 22:03:18

标签: c++

我需要在多个类中使用iostream作为项目,我收到此错误。我试图在其他地方添加inputStream,但我不完全确定问题是什么。 (我在标题中包含了iostream。)

g++    -c -o Agency.o Agency.cpp
Agency.cpp:48:19: error: implicit instantiation of undefined template
      'std::__1::basic_ifstream<char, std::__1::char_traits<char> >'
    std::ifstream inputStream;
                  ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iosfwd:131:32: note: 
      template is declared here
    class _LIBCPP_TEMPLATE_VIS basic_ifstream;
                               ^
1 error generated.
make: *** [Agency.o] Error 1

任何提示? (这是用c ++编写的)代码如下:

void Agency::readAllData(Agency& agency, char *file) {
int i = 0;
char ch;
int tSensors = 0;

char Name[NAME_LENGTHS];
int ZIP[ZIP_LENGTH];

int Year;
char Make[NAME_LENGTHS];
char Model[NAME_LENGTHS];
float Price;
char sensorName[NAME_LENGTHS];
bool bAvailable;
char Owner[NAME_LENGTHS];

char strGPS[4] = "gps";
char strCamera[7] = "camera";
char strLidar[6] = "lidar";
char strRadar[6] = "radar";

std::ifstream inputStream;
inputStream.open(file);

// Read in information
Cars *inventory = agency.inventory;
Sensor *sensors = inventory->getSensors();

0 个答案:

没有答案