C++ eclipsec++;-无法解析字符串类型
我正在尝试构建一个头文件prog1.h,它当前的外观如下:C++ eclipsec++;-无法解析字符串类型,c++,eclipse,string,C++,Eclipse,String,我正在尝试构建一个头文件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;
#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_ */
\ifndef PROG1\u H_
#定义程序1_H_
#包括
#包括
#包括
#包括
使用名称空间std;
常量int NUMGRADES=5;
结构学生信息{
字符串id;
双级;
国际职系[NUMGRADES];
};
int ReadGrades(istream&input,StudentInfo信息[]);
void HighestAverage(StudentInfo Info[],int numStudents,string&id,double&maxAv);
#endif/*PROG1_H_*/
但是,字符串标识符带有下划线,Eclipse表示“字符串无法解析为类型”。我包含了所有内容,并且使用标准名称空间,那么有什么问题吗
谢谢大家! 尝试执行std::string并删除using。尝试执行std::string并删除using。您不应该将
using
语句抛出到全局命名空间中,尤其是在头文件中。您不应该将using
语句抛出到全局命名空间中,尤其是在头文件中。