Eclipse C++ - 无法解析字符串类型

Eclipse C++ - cannot resolve string type

本文关键字:字符串 类型 C++ Eclipse      更新时间:2023-10-16

>我正在尝试构建一个头文件prog1.h,目前如下所示:

#ifndef PROG1_H_
#define PROG1_H_
#include <fstream>
#include <string>
#include <cstdlib>
#include <iostream>
using namespace std;
const int NUMGRADES = 5;
struct StudentInfo{
    string id;
    double avGrade;
    int grades[NUMGRADES];
};
int ReadGrades(istream & input, StudentInfo Info[]);
void HighestAverage(StudentInfo Info[], int numStudents, string & id, double & maxAv);
#endif /* PROG1_H_ */

但是,字符串标识符带有下划线,Eclipse 表示"字符串无法解析为类型"。我包含了所有内容并使用标准命名空间,那么有什么问题?

谢谢!

尝试执行 std::string 并删除使用。