ADT Employee
ADT Employee
07 - Programming Exercises
Employee ADT
Program the following task in your C++ compiler. Keep compiling and executing even after writing a single
line of code.
ADT: Employee
Write a class named Employee for which each object can hold information about a particular employee:
1. The class should have the following four private data members.
• A constructor that accepts employee’s name, id, department, and position as arguments and assigns them to the
appropriate member variables.
• A constructor that accepts employee’s name and id number as arguments and assigns them to the appropriate member
variables. The department and position fields should be assigned an empty string ("").
• A default constructor that assigns empty string ("") to the name, department, and position member variables, and 0 to
the id member variable.
• A destructor that does nothing except displaying a simple message "Destructor executed…" on the screen.
3. Provide the implementation of properties methods (get/set) for all the data members (name, id, department, and position) of
the class.
• setInfo method accepts employee’s name, id, department, and position as arguments and assigns them to the appropriate
member variables.
• getInfo method to initialize the data of an employee taken from the user through the console.
5. Test the functionality of Employee class by creating its five objects to hold the following data in main function,
The program should store this data in the five objects and then display the data for each employee on the screen in the appropriate
format.
☺ ☺ ☺ The most certain way to succeed is always to try just one more time. ☺ ☺ ☺
Umair Babar, FCIT – PU. Lahore. Page 1 of 1