Definition:
Write a C++ program to define a Employee class with the following Members:
Data Members: empid, emp salary
Member Functions: to read a data and to print the data.
Program should use array within class to read 3 employee information and print the 3 employee information.
Source Code for C++ program to read and print Employee information
#include
using namespace std;
class Employee
{
private:
int empid[3];
int empsal[3];
public:
void read_data();
void print_data();
};
void Employee::read_data()
{
for (int i=0; i<3;i++)
{
cout<<"Enter the Employee ID. ";
cin>>empid[i];
cout<<"Enter the Employee salary. ";
cin>>empsal[i];
}
}
void Employee::print_data()
{
for (int i=0; i<3;i++)
{
cout<
Output:
Enter the Employee ID. 123
Enter the Employee salary. 10000
Enter the Employee ID. 234
Enter the Employee salary. 20000
Enter the Employee ID. 345
Enter the Employee salary. 30000
Employee Information is:
EmpID EMP Salary
123 10000
234 20000
345 30000