| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 510 人关注过本帖
标题:定义了类为什么还是'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
快速回复:定义了类为什么还是'Student' : undeclared identifier???高手帮帮 ...
数据加载中...
 
   



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

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