📄 student.h
字号:
#include<fstream.h>
class student{
public:
student(){};
~student(){};
student(student&stu){
strcpy(name,stu.name),strcpy(id,stu.id),strcpy(sex,stu.sex),
strcpy(sub1,stu.sub1),strcpy(sub2,stu.sub2),strcpy(sub3,stu.sub3),
strcpy(sub4,stu.sub4),strcpy(sub5,stu.sub5),strcpy(sub6,stu.sub6),
strcpy(sub7,stu.sub7),strcpy(sub8,stu.sub8);
}
friend void addstudent(student&stu,char *pname,char *nid,char *psex,char *psub1,
char *psub2,char *psub3,char *psub4,char *psub5,
char *psub6,char *psub7,char *psub8);
friend void editstudent(student&stu,char *pname,char *nid,char *psex,char *psub1,
char *psub2,char *psub3,char *psub4,char *psub5,
char *psub6,char *psub7,char *psub8);
char *getname(){return name;}
char *getid(){return id;}
char *getsex(){return sex;}
int getrang(){return rang;}
void setrang(int r){rang=r;}
double gettotal(){
double total=atof((LPCTSTR)getsub1())+
atof((LPCTSTR)getsub2())+atof((LPCTSTR)getsub3())+
atof((LPCTSTR)getsub4())+atof((LPCTSTR)getsub5())+
atof((LPCTSTR)getsub6())+atof((LPCTSTR)getsub7())+
atof((LPCTSTR)getsub8());
return total;
}
char *getsub1(){return sub1;}
char *getsub2(){return sub2;}
char *getsub3(){return sub3;}
char *getsub4(){return sub4;}
char *getsub5(){return sub5;}
char *getsub6(){return sub6;}
char *getsub7(){return sub7;}
char *getsub8(){return sub8;}
private:
int nodel,rang;
char name[10],id[20],sex[4];
char sub1[3],sub2[3],sub3[3],sub4[3];
char sub5[3],sub6[3],sub7[3],sub8[3];
};
student stu[100];
int count=-1,flag=0;
CString id;
void addstudent(student &stu,char *pname,char *nid,char *psex,char *psub1,
char *psub2,char *psub3,char *psub4,char *psub5,
char *psub6,char *psub7,char *psub8){
strcpy(stu.name,pname),strcpy(stu.id,nid),strcpy(stu.sex,psex),strcpy(stu.sub1,psub1),
strcpy(stu.sub2,psub2),strcpy(stu.sub3,psub3),strcpy(stu.sub4,psub4),strcpy(stu.sub5,psub5),
strcpy(stu.sub6,psub6),strcpy(stu.sub7,psub7),strcpy(stu.sub8,psub8);
}
void savestudent(){
fstream ofn("data.yil",ios::out);
for(int i=0;i<count;i++){
ofn.write((char*)&stu[i],sizeof(stu[i]));
}
ofn.close();
AfxMessageBox("保存成功!");
}
void editstudent(student&stu,char *pname,char *nid,char *psex,char *psub1,
char *psub2,char *psub3,char *psub4,char *psub5,
char *psub6,char *psub7,char *psub8){
strcpy(stu.name,pname),strcpy(stu.id,nid),strcpy(stu.sex,psex),strcpy(stu.sub1,psub1),
strcpy(stu.sub2,psub2),strcpy(stu.sub3,psub3),strcpy(stu.sub4,psub4),strcpy(stu.sub5,psub5),
strcpy(stu.sub6,psub6),strcpy(stu.sub7,psub7),strcpy(stu.sub8,psub8);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -