标题:定义了类为什么还是'Student' : undeclared identifier???高手帮帮忙~~
取消只看楼主
韩雨航
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2012-1-12
结帖率:57.14%
已结贴  问题点数:10 回复次数:0 
定义了类为什么还是'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();
}
搜索更多相关主题的帖子: class void average display include 
2012-02-18 22:27



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-361147-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.755559 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved