-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem_9.cpp
More file actions
44 lines (41 loc) · 906 Bytes
/
Problem_9.cpp
File metadata and controls
44 lines (41 loc) · 906 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
#include <iostream>
#include <limits> // For numeric_limits
using namespace std;
class managers
{
string name;
int age;
public:
void get_data()
{
cout << "Name: " << name << endl;
cout << "Age: " << age << endl;
}
void set_data(string name, int age)
{
this->name = name;
this->age = age;
}
};
int main()
{
managers m[3];
string name;
int age;
for (int i = 0; i < 3; i++)
{
cout << "Enter name of Employee: ";
cin >> ws; // To ignore leading whitespaces
getline(cin, name);
cout << "Enter age of the Employee: ";
cin >> age;
m[i].set_data(name, age);
// Clear the input buffer to handle the newline character
// cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
for (int i = 0; i < 3; i++)
{
m[i].get_data();
}
return 0;
}