-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessenger.cpp
More file actions
71 lines (65 loc) · 1.35 KB
/
messenger.cpp
File metadata and controls
71 lines (65 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include <stdlib.h>
using namespace std;
int main();
void menu();
struct User{
string name;
string sent[50];
string inbox[50];
};
class Messeger
{
private:
User *user;
int n;
public:
void Register()
{
cout << "Input User" ;
cin >> n;
user = new User[n];
for(size_t i =0 ;i<n;i++)
{
cout << "User["<<i+1<<"] "<<"Name:";
cin >> user[i].name;
}
}
void showUser()
{
cout << n <<endl;
for(int i =0 ;i<n;i++)
{
cout << "User[" << i+1 << "] " << "Name:";
cout << user[i].name << endl;
}
cout << "Press any to continue!" << endl;
int tmp;
cin >> tmp;
menu();
}
};
//should not declare object in loop function or recursive
Messeger user;
void menu()
{
int x;
system("clear");
cout << "1.Register" << endl;
cout << "2.Show all users" << endl;
cout << "3.See the conversations" << endl;
cout << ":";cin >> x;
switch(x)
{
//use break to prevent recursive
case 1:user.Register();menu();break;
case 2:user.showUser();break;
case 0:break;
default:menu();
}
}
int main()
{
menu();
return 0;
}