Question: Create a base class called Employee with the following attributes: name ( string ) , id ( int ) , salary ( double ) Add

Create a base class called Employee with the following attributes:
name (string), id (int), salary (double)
Add a constructor and a member function display Info() that prints the employee's information in the Employee class.
Derive the following classes from Employee:
Manager, Engineer, Intern
3. Add specific attributes and methods for each derived class:
Manager:
Additional attribute numOfTeams (int)
Method displayInfo() to show details of the Manager, including numOfTeams
Engineer:
Additional attribute specialization (string)
Method displayInfo() to show details of the Engineer, including specialization
Intern:
Additional attribute duration (int)(in months) Method displayInfo() to show details of the Intern, including duration
Demonstrate polymorphism by creating a function printEmployeeDetails() that takes a pointer or reference to an Employee and calls the displayInfo() function.
Write a main() function to:
Create objects of each derived class (Manager, Engineer, Intern) and call their respective displayInfo() methods using both an object and a base class pointer.
Call printEmployeeDetails() with different types of employee objects to demonstrate polymorphism.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!