学生信息管理系统面向对象设计c++Word格式文档下载.docx

上传人:b****2 文档编号:615222 上传时间:2023-04-29 格式:DOCX 页数:20 大小:17.94KB
下载 相关 举报
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第1页
第1页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第2页
第2页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第3页
第3页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第4页
第4页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第5页
第5页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第6页
第6页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第7页
第7页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第8页
第8页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第9页
第9页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第10页
第10页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第11页
第11页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第12页
第12页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第13页
第13页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第14页
第14页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第15页
第15页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第16页
第16页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第17页
第17页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第18页
第18页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第19页
第19页 / 共20页
学生信息管理系统面向对象设计c++Word格式文档下载.docx_第20页
第20页 / 共20页
亲,该文档总共20页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

学生信息管理系统面向对象设计c++Word格式文档下载.docx

《学生信息管理系统面向对象设计c++Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《学生信息管理系统面向对象设计c++Word格式文档下载.docx(20页珍藏版)》请在冰点文库上搜索。

学生信息管理系统面向对象设计c++Word格式文档下载.docx

intage;

inttag;

num=t.getnum();

name=t.getname();

sex=t.getsex();

age=t.getage();

tag=t.gettag();

os<

num<

'

'

name<

sex<

age<

<

tag<

endl;

returnos;

}

//Non-memberoverloaded>

>

operator.

istream&

operator>

(istream&

is,Student&

charname[50];

is>

num>

name>

sex>

age>

tag;

t.setnum(num);

t.setname(name);

t.setsex(sex);

t.setage(age);

t.settag();

returnis;

voidAct:

:

add()

{

Students,s1;

ofstreamfile("

std.txt"

ios:

app);

//追加!

不同于ate!

打开一个输出文件用于在文件尾添加数据

while

(1)

{

cout<

"

请输入一个学生信息:

(学号、姓名、性别(W:

代表女性woman,M:

代表男性man)、年龄)"

//file>

s;

cin>

age;

s.setnum(num);

s.setname(name);

s.setsex(sex);

s.setage(age);

s.settag();

file<

学生信息添加成功\n"

是否继续输入学生信息:

(Y/N)"

c;

if(c=='

n'

||c=='

N'

break;

}

file.close();

display()

top=-1;

Students[1000],s1;

//s[n],n不能太大!

ifstreamfile("

);

//fstreamfile("

d:

\\std.txt"

ios_base:

out);

//file.read((char*)&

s,sizeof(s));

//file.read(reinterpret_cast<

char*>

(&

s),sizeof(s));

file>

s1;

if(!

file.eof())

//安排位置要注意,以防多输出随机数据

top++;

\t\t第"

top+1<

个学生信息:

(学号、姓名、性别、年龄、标识符)\n"

\t\t"

s1<

s[top]=s1;

query()

intc2;

Student*s;

//一个临时的指针

cout<

1按学号来查询:

"

2按姓名来查询:

\t\t请选择:

\n"

cin>

c2;

switch(c2)

case1:

请输入要查询的学生的学号:

longnum;

num;

s=querybynum(num);

if(s==NULL)

cout<

在文件中不含有该生信息..."

else

{cout<

setw(10)<

学号"

姓名"

性别"

年龄"

----------------------------------------------------------\t"

s->

display();

break;

}

case2:

请输入要查询的学生的姓名:

charname[50];

name;

s=querybyname(name);

default:

输入有误!

请重新输入!

\n"

//根据指定学号进行查找

Student*Act:

querybynum(longnum)

inttop=-1;

Students;

//cout<

hehe"

//file>

while(!

file>

//cout<

s.getnum()<

hejoou\n"

std[top]=s;

file.close();

for(inti=0;

i<

=top;

i++)

if(std[i].getnum()==num)

return&

std[i];

returnNULL;

//找不到,返回一个NULL值

querybyname(charname[])

binary);

file)

if(strcmp(std[i].getname(),name)==0&

&

std[i].gettag()==0)

modif()

charsex;

charyn;

//yorn

请输入要修改学生的学号:

在数据库中不含有该生信息..."

{

学生的学号是否需被修改?

(y/n)"

cin>

yn;

if(yn=='

Y'

||yn=='

{

cout<

请输入学生的新学号:

cin>

s->

setnum(num);

}

学生的姓名是否需被修改?

请输入学生的新姓名:

setname(name);

学生的性别是否需被修改?

请输入学生的新性别:

sex;

setsex(sex);

学生的年龄是否需被修改?

请输入学生的新年龄:

setage(age);

学生信息修改完毕,修改后的信息如下:

\n\n\n"

//file<

*s//error!

//老师,文件的输出,修改后的数据该如何输出,指针不是很会用诶

//if(std[i].gettag()==0)//只有没删除的才存盘!

file<

file.close();

}

del()

Students,*p=NULL;

intk=0,i;

请输入要删除学生的学号:

inttop=-1;

while(!

top++;

std[top]=s;

for(inti=0;

if(std[i].getnum()==num)

{

k=i;

break;

if(k<

0)

输入有误!

for(i=k;

top;

{

std[i]=std[i+1];

}

top--;

ofstreamfile("

for(i=0;

file<

删除成功!

//for(i=0;

//std[i]->

diplay();

是否继续删除?

(y/n):

if(yn=='

#endif/*_ACT_H*/

二、#ifndef_HEADER_H

#define_HEADER_H

#include<

iostream>

string>

fstream>

iomanip>

#endif/*_HEADER_H*/

三、

学生信息管理系统

forstd_head

#ifndef_STD_H

#define_STD_H

header.h"

classStudent

//定义标志位——0:

未删除;

1:

已删除

voidsetnum(longn);

voidsetname(charname[]);

voidsetsex(charsex);

voidsetage(intage);

voidsettag();

//此处不用参数,写在具体的函数体内,不需要用户知道

longgetnum();

char*getname();

//一定不能写成chargetname()

chargetsex();

intgetage();

intgettag();

//voidadd(longnum,charname[],charsex,intage);

voidStudent:

setnum(longn)

//this->

num=n;

//this指针存在于类的成员函数中,指向被调用函数所在的类实例的地址。

num=n;

setname(charname[])

strcpy(this->

name,name);

//strcpy(name,nam);

}//!

setsex(charsex)

this->

sex=sex;

//只是因为参数跟类成员变量重名了,得加this

setage(intage)

age=age;

 

settag()

tag=0;

longStudent:

getnum()

returnnum;

char*Student:

getname()

returnname;

charStudent:

getsex()

returnsex;

intStudent:

getage()

returnage;

gettag()

returntag;

num<

name<

setw(11)<

age<

/*voidStudent:

add(longnum,charname[],charsex,intage)

num=num;

}*/

tag=1;

#endif/*_STD_H*/

四、

#ifndef_UI_H

#define_UI_H

act.h"

classUi

voidmenu();

intc;

voidUi:

menu()

Actdb;

\n\n"

\t******●欢迎进入济南大学学生信息管理系统******"

\t****●添加学生信息,请按1****"

\t****●显示学生信息,请按2****"

\t****●查询学生信息,请按3****"

\t****●修改学生信息,请按4****"

\t****●删除学生信息,请按5****"

\t****●退出系统,请按0****"

请选择您要进行的操作:

switch(c)

getchar();

case1:

db.add();

break;

case2:

db.display();

case3:

db.query();

case4:

db.modif();

case5:

db.del();

case0:

exit(0);

default:

#endif/*_UI_H*/

五、

window.h>

ui.h"

intmain()

Uia;

a.menu();

return0;

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 工程科技 > 能源化工

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2