Question
#include #include using namespace std; class Employee { /* 3. Create a class called 'EMPLOYEE' that has -private fields: write integer empcode and char empname
#include
class Employee { /* 3. Create a class called 'EMPLOYEE' that has -private fields: write integer empcode and char empname with array size 10 as data members -public methods: write a void member function getdata() to input data and void member function display() to output data */
};
void Employee::getdata() { cout << " NAME :"; cin >> empname; cout << " CODE :"; cin >> empcode; }
void Employee::display() { cout << endl << setw(20) << empname << setw(10) << empcode << endl; }
/* 4. Write a main function to create EMP, an array of EMPLOYEE objects. Accepts and display the details of at least 6 employees. */
int main() { //Write Employee class to create Emp array size of 6 below:
cout << "Enter employee details: "; for (int i = 0; i < 6; i++) { cout << " employee " << i + 1 << endl; //Use the Emp object array to access the getdata method, write the content of the Emp array using the getdata() method below
} cout << " Employee details are as follows :"; cout << " " << setw(20) << "NAME" << setw(10) << "CODE"; cout << " --------------------------------"; //Display each of the Emp array by accessing the display method below.
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started