0% found this document useful (0 votes)
29 views1 page

ADT Employee

The document describes an Employee class that stores information about employees. It specifies private data members for an employee's name, ID number, department, and position. It provides details on implementing various constructors, destructor, getter/setter methods, and member functions to set, get, and display employee information. It concludes by describing how to test the class by creating 5 Employee objects to store sample data and display it.

Uploaded by

Meherun nisa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views1 page

ADT Employee

The document describes an Employee class that stores information about employees. It specifies private data members for an employee's name, ID number, department, and position. It provides details on implementing various constructors, destructor, getter/setter methods, and member functions to set, get, and display employee information. It concludes by describing how to test the class by creating 5 Employee objects to store sample data and display it.

Uploaded by

Meherun nisa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

O b j e c t O r i e n t e d P r o g r a m m i n g

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.

1) A string named name that holds the employee’s name.


2) An integer named id that holds the employee’s ID number.
3) A string named department that holds the name of the department where the employee works.
4) A string named position that holds the employee’s job title.

2. Provide the implementation of following constructors and a destructor.

• 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 copy constructor initializes an employee’s object with an already existing object.

• 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.

4. Provide the implementation of the following member functions.

• 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.

• putInfo method to display the information of a particular employee on the console.

5. Test the functionality of Employee class by creating its five objects to hold the following data in main function,

Name Id Number Department Position


Naveed Ali 1230 Computer Science Assistant Professor

Nouman Abdullah 1231 Software Engineering Lecturer

Naeem Ahmad 1241 Computer Science Lecturer

Nadia 1242 Information Technology Assistant Professor

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

You might also like