C++ 课程设计 作品 学生信息管理系统

/////////////////////////////////////

// 学生信息管理系统 //

// 52computer //

// 2008年12月25日 //

///////////////////////////////////

#include<iostream>
#include<string>
#include<fstream>
#include<conio.h>
#include<windows.h>
using namespace std;

/////////////////////////////////////

// 抽象基类 //

///////////////////////////////////
class Base
{
protected:
int id;//本科生,研究生识别
int num;
char name[20];
char sex[5];
double ch,en,ma;//成绩
int borth;

public:
Base();
virtual int getid()=0;//本科生,研究生识别
virtual void set()=0;//纯虚函数,在派生类中调用
virtual void display()=0;
double getsum();//取总成绩
char * getsex();//取性别
double getch();//取各科成绩
double geten();
double getma();
int getborth();
int getnum();//取学号
char* getname();//取姓名
};


Base::Base()//基类构造
{
num=0;
strcpy(name,"No name");
ch=0;en=0;ma=0;
borth=1900;
}

int Base::getborth()
{return borth;}

double Base::getsum()
{return ch+en+ma;}

double Base::getch()
{return ch;}

double Base::geten()
{return en;}

double Base::getma()
{return ma;}

int Base::getnum()
{return num;}

char *Base::getsex()
{return sex;}

char * Base::getname()
{return name;}


/////////////////////////////////////

// 本科生类 //

///////////////////////////////////
class College:public Base//本科生类
{
private:
int id;//本科生识别
char subject[20];//专业
public:
College();//College构造
int getid();//本科生识别
char* getsub();
void set();
void display();
friend ostream& operator<<(ostream&,const College&);
friend istream& operator>>(istream&,College&);
};
void College::set()
{
cout<<"输入本科生信息\n"<<"学号 姓名 性别(man/woman) 专业 三科成绩 出生年\n";
cin>>num>>name>>sex>>subject>>ch>>en>>ma>>borth;
}

College::College():Base()//College构造
{
id=0;
strcpy(subject,"Computer");
}

char*College::getsub()
{return subject;}

int College::getid()
{return id;}

void College::display()//打印
{
cout<<"\n本科生:\n"<<num<<" "<<name<<" "<<sex<<" "<<subject<<" "<<(ch+en+ma)/3<<" "<<(2008-borth)<<endl;
}

//本科生类中重载输入输出符
ostream& operator<<(ostream& out,const College& right)
{

out<<right.num<<" "<<right.name<<" "<<right.sex<<" "<<right.subject<<" "<<(right.ch+right.en+right.ma)/3<<" "<<(2008-right.borth)<<endl;
return out;
}

istream& operator>>(istream& in,College& right)
{

in>>right.num>>right.name>>right.sex>>right.subject>>right.ch>>right.en>>right.ma>>right.borth;
return in;
}

/////////////////////////////////////

// 研究生类 //

/////////////////////////////

你可能喜欢

  • 课程中心
  • 中国文化
  • 旅游经济学
  • 数据结构课程设计
  • 数据结构设计
  • 桩基础课程设计
  • 机械设计课程

C++ 课程设计 作品 学生信息管理系统相关文档

最新文档

返回顶部