-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path13.cpp
41 lines (36 loc) · 894 Bytes
/
13.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
//WAP to implementing an array of objects in a class using member functions to input & display data.
#include<iostream>
using namespace std;
class employee
{
private:
int id;
int age;
float salary;
public:
void displaydata(int i);
void setdata(int i)
{
cout<< "Enter "<< i <<" Employee ID: ";
cin>> id;
cout<< "Enter "<< i <<" Employee Age: ";
cin>> age;
cout<< "Enter "<< i <<" Employee Salary: ";
cin>> salary;
}
};
void employee:: displaydata(int i)
{
cout<< "\nEmployee " << i <<" ID: " << id <<" \nAge: " << age <<" \nSalary: " << salary <<"\n\n";
}
int main()
{
int i;
employee one[4];
for(i=1;i<=4;i++)
{
one[i].setdata(i);
one[i].displaydata(i);
}
return 0;
}