-
Notifications
You must be signed in to change notification settings - Fork 0
/
Array-of-object.cpp
68 lines (52 loc) · 971 Bytes
/
Array-of-object.cpp
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
#include <iostream>
using namespace std;
class emp
{
int id;
int salary;
public:void setId ()
{
cout << "Enter the Id of the employee : " << endl;
cin >> id;
cout << "Enter the salary of the employee : " << endl;
cin >> salary;
}
void getId ()
{
cout << "The Id of the Employee is : " << endl;
cout << id << endl;
cout << "The of salary of the Employee " << id << " is : " << salary <<
endl;
}
};
int
main ()
{
int ent;
cout << "How many entries you want to submit : " << endl;
cin >> ent;
emp str[ent];
for (int i = 0; i < ent; i++)
{
str[i].setId ();
}
int dat;
cout << "Press 1 to show salary with Id of the Employee | Press 2 to exit :"
<< endl;
cin >> dat;
if (dat == 1)
{
for (int i = 0; i < ent; i++)
{
str[i].getId();
}
if(dat==2)
{
cout<<"Thank You "<<endl;
}
else{
cout<<"incorrect input"<<endl;
}
}
return 0;
}