定义了类为什么还是'Student' : undeclared identifier???高手帮帮忙~~
//=======================//student.h
//========================
#ifdef HEADER_STUDENT
#define HEADER_STUDENT
#include<iostream.h>
class Student
{
string name;
int semesterhours;
double average;
public:
Student(string pname="noname"):name(pname),semesterhours(0),average(0){}
void addcourse(int hours,double grade)
{
double allgrade=(semesterhours*average+grade);
semesterhours+=hours;
average=semesterhours?allgrade/semesterhours:0;
}
void display()
{
cout<<"name=\""<<name<<"\""<<","<<"semesterhours="<<semesterhours<<","<<"average="<<average<<endl;
}
int gethours(){return semesterhours;}
double getaverage(){return average;}
};
#endif //HEADER_STUDENT
//=======================
//graduatestudent.h
//========================
#ifdef HEADER_GRADUATESTUDENT
#define HEADER_GRADUATESTUDENT
#include"student.h"
#include<iostream.h>
//---------------------
class Advisor
{
int noofmeeting;
};
class Graduatestudent public:Student
{
Advisor advisor;
int qualifiergrade;
public:
Graduatestudent(string pname="noname"):Student(pname),qualifiergrade(0){}
int getqualifier(){return qualifiergrade;}
void display()
{
Student::display();
std::cout<<"qualifiergrade="<<qualifiergrade<<endl;
}
};
#endif //HEADER_GRADUATESTUDENT
//===================
//inheritance & member override
//====================
#include"student.h"
#include"graduatestudent.h"
#include<iostream.h>
//------------------------
int main()
{
Student ds("han yu hang");
Graduatestudent gs;
ds.addcourse(3,2.5);
ds.display();
gs.addcourse(3,3.0);
gs.display();
}