C++ 头文件中的结构类型错误

C++ 头文件中的结构类型错误,c++,compiler-construction,struct,header,initialization,C++,Compiler Construction,Struct,Header,Initialization,我试图在头文件中使用结构类型,然后在主文件中对其进行初始化,但继续出现错误: “没有用于调用'gradingStudent::gradingStudent()'的匹配函数” 头文件 #ifndef HEADERFILE_H #define HEADERFILE_H #include <iostream> #include <fstream> #include <string> #include <iomanip> using nam

我试图在头文件中使用结构类型,然后在主文件中对其进行初始化,但继续出现错误:

“没有用于调用'gradingStudent::gradingStudent()'的匹配函数”

头文件

#ifndef    HEADERFILE_H
#define    HEADERFILE_H

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>

using namespace std;

struct gradingStudent
{

   string studentName; //student's name

   int amtGradesHW;
   int amtGradesPro;
   int amtGradesExam; //number of homework programs

   float perTotHW;
   float perTotPro;
   float perTotExams; //percent the grade is worth

   float HWGradeRecieved;
   float ProGradeRecieved;
   float ExamGradeRecieved; //points recieved

   float TotalPercentage; //final grade recieved

   char X; //letter grade

   string wittyComment; //comment on grade

   int const MAX; 

   }; 
int openFiles(ifstream&, ofstream&);

#endif
\ifndef HEADERFILE\u H
#定义头文件
#包括
#包括
#包括
#包括
使用名称空间std;
结构分级学生
{
string studentName;//学生姓名
int amtGradesHW;
int amtGradesPro;
int-amtGradesExam;//作业程序的数量
浮萍;
浮动perTotPro;
浮动perTotExams;//分数的价值百分比
已收到的浮点数;
收到的浮点数;
float ExamGradeRecieved;//收到的点数
浮动总百分比;//收到的最终成绩
char X;//字母等级
字符串wittyComment;//对等级进行注释
int const MAX;
}; 
int openFiles(ifstream&,ofstream&);
#恩迪夫
编程分配.cpp

#include <iostream>
#include <fstream>
#include <string>
#include "HeaderFile.h"

using namespace std;

int main(){



ifstream inFile; //input file variable
ofstream outFile; //output file stream

gradingStudent grades; //intialize my struct 

//Test If files can be opened
if(!openFiles(inFile, outFile)){ 
cout << "...exiting " << endl;
system("pause");
                       }//end if





}//end main

/*
* Input: ifstream and ofstream
* Return Type: int
*
* OpenFiles will ask the user for the files to be opened and check if they are able to          be opened
   * usage: openFiles(inFile, OutFile)
  **/

   int openFiles(ifstream& inD, ofstream& outD){

string inFileName, outFileName;  

cout << "Please enter the name of the file to be read: " << endl;
cin >> inFileName;
cout << "    " << endl; 

inD.open(inFileName.c_str()); //open this file
if (!inD)
{
       cout << "ERROR. THE INPUT FILE: " << inFileName << " WAS UNABLE TO BE      OPENED!"     << endl ; 
       cout << "      " << endl;     

       return 0;
            }//end input  if fail state


    cout << "Please enter the name of the file to be written: " << endl;
    cin >> outFileName;
    cout << "    " << endl;                

        outD.open(outFileName.c_str()); //open this file

        if (!outD)
{
       cout << "ERROR. THE OUTPUT FILE: " << outFileName <<  " WAS UNABLE TO BE         OPENED!" << endl ; 
       cout << "      " << endl;     

       return 0;
            }//end output if fail state     

}//end open file
#包括
#包括
#包括
#包括“HeaderFile.h”
使用名称空间std;
int main(){
ifstream infle;//输入文件变量
ofstream outFile;//输出文件流
分级学生成绩;//初始化我的结构
//测试是否可以打开文件
如果(!openFiles(infle,outFile)){

cout您有一个
const
(和非
static
)成员变量(
MAX
),需要显式初始化该变量。因此,您必须显式定义类的构造函数