student.h

来自「用C++写的一个简单学籍管理系统」· C头文件 代码 · 共 85 行

H
85
字号
# pragma once

#ifndef _STUDENT_H_
#define _STUDENT_H_

#include <iostream>
#include <iomanip>
#include<list>
#include "person.h"
#include "course.h"
using namespace std;

enum COMPARE
{
	BY_ID,
	BY_NAME,
	BY_AVG_SCORE,
	BY_SUM_SCORE,
	BY_SEX,
};

class Student:public Person
{
	
public:
	int crsNum;
	Student( const char *,const int =-1,const Sex =MALE,const COMPARE = BY_ID);
	Student( const string="" ,const int =-1,const Sex =MALE,const COMPARE = BY_ID);
	Student( const Person& );
	Student( const Student &);
	~Student();

	Student & operator = ( const Student &);
	bool operator == (const Student &) const;
	bool operator>(const Student &)const;
	bool operator<(const Student &)const;
	bool operator>=(const Student &)const;
	bool operator<=(const Student &)const;

	void addCourse(Course &);
	bool deleteCourse(Course &);
	void write(ostream &);
	void read( istream &);
	float getAverageScore()const;
	float getSumScore()const;
	void setFlag(const COMPARE);
	void printBase();
	void printDetail();

	void printCourses(int id)
	{
		list<Course>::iterator iBegin = courses.begin();
		list<Course>::iterator iEnd = courses.end();
		while(iBegin!= iEnd)
		{
			cout<<"Cname="<<(*iBegin).getId()<<",Cid="<<(*iBegin).getId()<<",Cscore= "<<(*iBegin).getScore()<< endl;
			iBegin++;
		}
	}

#ifdef _DEBUG_
	void printCourses()
	{
		list<Course>::iterator iBegin = courses.begin();
		list<Course>::iterator iEnd = courses.end();
		while(iBegin!= iEnd)
		{
			(*iBegin).printCourse();
			iBegin++;
		}
	}

	void printStudent()
	{
		cout<<"Sname= "<<name<<", Sid= "<<id<<", Sex="<<sex<<",crsNum= "<<crsNum<<endl;
		printCourses();
	}
#endif

public:
	list<Course> courses;
	COMPARE flag;
};
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?