Skip to content

Commit fed6035

Browse files
committed
解决了头文件编译报错的问题,增加了主页面对Linux的支持
1 parent 492b2b3 commit fed6035

File tree

5 files changed

+32
-31
lines changed

5 files changed

+32
-31
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22
支持多用户的学管系统
33

44

5-
存在问题:多次引用sleep_cls.h会报错
6-
登录界面支持linux,主界面引不了sleep_cls.h,只支持win32
7-
85
支持多用户登录,修改账号密码
96

107
md5加密源代码来自 https://blog.csdn.net/m0_46632317/article/details/127039490
118

12-
运行环境:vscode即可
9+
运行环境:vscode默认配置下编译所有cpp文件即可

fun_load.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ using namespace std;
1111

1212
Password ps;
1313
fstream key;
14-
14+
My_sleep_cls Koishi;
1515
map<string, string> login;
1616
map<string, string>::iterator key_it;
1717

@@ -21,7 +21,7 @@ int student::welcome()
2121
{
2222
cout << "用户密码存储文件信息缺失,即将被迫回档,重新注册!\n***您可能会失去已有数据***\n按任意键继续... ";
2323
_getch();
24-
my_cls();
24+
Koishi.my_cls();
2525
re_gister(true);
2626
return 0;
2727
}
@@ -51,7 +51,7 @@ void student::welcome2()
5151
for (char *i = weltxt3; *i != '\000'; *i++)
5252
{
5353
putchar(*i);
54-
my_sleep(8);
54+
Koishi.my_sleep(8);
5555
}
5656
_getch();
5757
re_gister(true);
@@ -120,7 +120,7 @@ void student::re_gister(bool n_ew)
120120
}
121121
cout << "\n修改密码成功!即将返回初始界面!\n 按任意键继续...";
122122
_getch();
123-
my_cls();
123+
Koishi.my_cls();
124124
return;
125125
}
126126
else
@@ -137,14 +137,14 @@ void student::re_gister(bool n_ew)
137137
_getch();
138138
return;
139139
}
140-
my_cls();
140+
Koishi.my_cls();
141141

142142
for (int i = 3; i > 0; i--)
143143
{
144144
cout << "\t\t\t账户已创建完成,请登录。\n";
145145
cout << "\t\t\t" << i << "秒后返回到主页面……" << endl;
146-
my_sleep(1000);
147-
my_cls();
146+
Koishi.my_sleep(1000);
147+
Koishi.my_cls();
148148
}
149149
return;
150150
}
@@ -160,7 +160,7 @@ void student::lo_ad()
160160
for (char *i = weltxt1; *i != '\000'; *i++)
161161
{
162162
putchar(*i);
163-
my_sleep(8);
163+
Koishi.my_sleep(8);
164164
}
165165
while (1)
166166
{
@@ -180,7 +180,7 @@ void student::lo_ad()
180180
for (char *i = weltxt2; *i != '\000'; *i++)
181181
{
182182
putchar(*i);
183-
my_sleep(8);
183+
Koishi.my_sleep(8);
184184
}
185185
while (1)
186186
{
@@ -198,13 +198,13 @@ void student::lo_ad()
198198
continue;
199199
}
200200
}
201-
my_cls();
201+
Koishi.my_cls();
202202
for (int i = 3; i > 0; i--)
203203
{
204204
cout << "\t\t\t登陆成功!\n";
205205
cout << "\t\t\t" << i << "秒后将进入系统……" << endl;
206-
my_sleep(1000);
207-
my_cls();
206+
Koishi.my_sleep(1000);
207+
Koishi.my_cls();
208208
}
209209
dat_name = ID + ".dat";
210210
return;

fun_main.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
#include <conio.h>
44
#include <list>
55
#include "class_student.hpp"
6-
// #include "sleep_cls.hpp"
6+
#include "sleep_cls.hpp"
77

88
using namespace std;
99

1010
fstream dat;
1111
list<Tmp_dat> sort_list_stu;
1212
list<Tmp_dat> list_student;
1313
list<Tmp_dat>::iterator it;
14-
14+
My_sleep_cls Marisa;
1515
void student::start()
1616
{
1717
while (1)
@@ -22,7 +22,7 @@ void student::start()
2222
if (!menu())
2323
break;
2424
}
25-
system("cls");
25+
Marisa.my_cls();
2626
return;
2727
}
2828
bool student::init()
@@ -99,7 +99,7 @@ bool student::save()
9999
int student::menu()
100100
{
101101
int n;
102-
system("cls");
102+
Marisa.my_cls();
103103
cout << "\t\t\t**********欢迎来到学生信息管理系统**********" << '\n';
104104
cout << "\t\t\t你可以进行以下操作:" << '\n';
105105
cout << "\t\t\t|------------------------------------------|" << '\n';
@@ -150,7 +150,7 @@ int student::menu()
150150

151151
int student::look_s()
152152
{
153-
system("cls");
153+
Marisa.my_cls();
154154
cout << "\t\t\t请选择排序方法:\n";
155155
cout << "1.学号\n";
156156
cout << "2.姓名\n";
@@ -370,7 +370,7 @@ int student::del_s()
370370

371371
int student::count_s()
372372
{
373-
system("cls");
373+
Marisa.my_cls();
374374
cout << "\t\t\t请选择要统计的信息:\n";
375375
cout << "1.总人数\n";
376376
cout << "2.平均分\n";

main.exe

-633 KB
Binary file not shown.

sleep_cls.hpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,24 @@
44
#else
55
#include <unistd.h>
66
#endif
7-
void my_sleep(unsigned int ms)
7+
class My_sleep_cls
88
{
9+
public:
10+
void my_sleep(unsigned int ms)
11+
{
912
#ifdef _WIN32
10-
Sleep(ms);
13+
Sleep(ms);
1114
#else
12-
usleep(ms * 1000);
15+
usleep(ms * 1000);
1316
#endif
14-
}
17+
}
1518

16-
void my_cls()
17-
{
19+
void my_cls()
20+
{
1821
#ifdef _WIN32
19-
system("cls");
22+
system("cls");
2023
#else
21-
system("clear");
24+
system("clear");
2225
#endif
23-
}
26+
}
27+
};

0 commit comments

Comments
 (0)