云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > C++学生信息管理系统(一卡通)

C++学生信息管理系统(一卡通)

  • 62 次阅读
  • 3 次下载
  • 2025/7/2 8:03:54

//由于对fsream的不熟练,不会对指定部分的数据的修改,因而删除了一些功能,同时也导致了只能对消费额进行加减,但不能导入txt文件。 Code:

Uni-card system.h

#include using namespace std; class person {

public:

void buildAdmin(); void buildUndergraduate(); void buildPostgraduate(); protected:

char name[20]; char sex; char shape[10]; char tel[12]; };

class consumer:public person {

protected:

double money; };

class student :public consumer //定义学生类 {

protected:

char number[20]; int age;

char nowClass[20]; char birthPlace[20]; };

class admin :public person //定义管理员类 {

public:

void login(); void adminRegister();

void adminRegister2(); private:

char account[12]; char password[12]; char title; };

class undergraduate :public student //定义本科生类 {

public:

void searchUndergraduate(); void displayUndergraduate(); void inputUndergraduate_wrapper(); void inputUndergraduate(); void inputUndergraduate1(); void underPayout(char str[]); void monitorPower();

void outputClassStudent(char s[]); void underSearchAll(); private:

char monitor; };

class postgraduate :public student //定义研究生类 {

public:

void searchPostgraduate(); void displayPostgraduate(); void inputPostgraduate_wrapper(); void inputPostgraduate(); void inputPostgraduate1(); void postPayout(char str[]); void postSearchAll(); protected: double wage; };

//不清楚教职工是否配备有一卡通,所以暂不考虑教职工类

Uni-card system.cpp #include #include #include #include

#include #include %using namespace std; void onUndergraduate(); void onPostgraduate(); bool comp(char s1[],char s2[]); void inputStudent(); void adminOnLogin();

//------------------------------------------------------------------

//---------------------以下为person类中成员函数--------------------- //------------------------------------------------------------------ void person::buildAdmin() //建立Admin.txt {

fstream file(\打开文件,指针指向文件尾 }

void person::buildUndergraduate() //建立Undergraduate.txt {

fstream file(\打开文件,指针指向文件尾 }

void person::buildPostgraduate() //建立Postgraduate.txt {

fstream file(\打开文件,指针指向文件尾 }

//------------------------------------------------------------------

//--------------------以下为admin类中成员函数----------------------- //------------------------------------------------------------------ void admin::login() //管理员登录及验证 {

int ensurance=0;

char account2[12],password2[12]; admin ad; cout << endl

<< \ ★★★★★管理员登录界面★★★★★\ cout << \ 请输入您的账号: \ cin >> account2;

cout << \ 请输入您的密码:\ cin >> password2;

fstream file(\打开文件,指针在文件头

file.read((char*)&ad,sizeof(ad)); //读取类信息

while(!file.eof()) //判断文件指针是否到文件尾 {

file.close(); //关闭文件 file.close(); //关闭文件 file.close(); //关闭文件

if(comp(ad.account,account2)&&comp(ad.password,password2)) //判断输入的字符

是否与文件中的一样 {

cout << \ 登录成功!\ ensurance=1;break; } }

void admin::adminRegister() //管理员在文件外录入信息 {

admin adm; char choose; int loop=1,loop1=1; cout << endl

<< \ ★★★★★管理员注册★★★★★\ while(loop1) {

loop1=0;

cout << \ 输入您的账号(12位以内):\ fstream file(\打开文件,指针在文件头 file.read((char*)&adm,sizeof(adm)); //读取类信息

while(!file.eof()) //判断文件指针是否到文件尾 {

if(comp(adm.account,account)) //判断输入的字符是否与文件中的一样 {

cout << \ 账号已被占用!\ loop1=1; break; }

file.read((char*)&adm,sizeof(adm));//如果指针没到文件尾,继续读取 }

file.close(); }

cout << \ 输入您的密码(12位以内):\ cout << \ 输入您的姓名:\ while(loop) {

cout << \ 选择您的性别(A.男,B.女):\ cin >> choose;

}

file.close();

if(ensurance==0) cout << \ 您的账号或密码输入错误!\file.close(); //关闭文件 if(ensurance) adminOnLogin();

file.read((char*)&ad,sizeof(ad));//如果指针没到文件尾,继续读取

搜索更多关于: C++学生信息管理系统(一卡通) 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

//由于对fsream的不熟练,不会对指定部分的数据的修改,因而删除了一些功能,同时也导致了只能对消费额进行加减,但不能导入txt文件。 Code: Uni-card system.h #include using namespace std; class person { public: void buildAdmin(); void buildUndergraduate(); void buildPostgraduate(); protected: char name[20]; char sex; char shape[10]; char tel[12]; }; <

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com