-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStruct1.cpp
More file actions
57 lines (45 loc) · 940 Bytes
/
Struct1.cpp
File metadata and controls
57 lines (45 loc) · 940 Bytes
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
#include <iostream>
#include <stdlib.h>
#include <string.h>
using namespace std;
typedef struct People
{
private:
string name;
int age;
public:
void setName()
{
string SetName;
cout << "Enter the user name: ";
getline(cin, SetName);
this->name = SetName;
}
string getName()
{
return this->name;
}
void setAge()
{
int SetAge;
cout << "Enter the users age: ";
cin >> SetAge;
this->age = SetAge;
}
int getAge()
{
return this->age;
}
}People;
int main()
{
People user;
user.setName();
user.setAge();
cout << endl << "USER NAME: " << user.getName();
cout << endl << "USER AGE : " << user.getAge();
cout << endl;
for(int i = 0; i < 50; i++) cout << "=";
cout << endl << endl << "Press enter to continue...";
setbuf(stdin, 0); getchar();
}