Home Activity Consider the class class base { public: virtual void iam) { cout << "base\n"; }; Derive two classes from class base, and for each define iam() to write out the a. name of the class. b. Declare objects of each class, and call iam) from them. c. iam() through the pointers. Assign the address of objects of the derived classes to base pointers and call d. Remove the virtual keyword from the base class member function, run your code again, and compare the results.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter13: Overloading And Templates
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question
Please solve solve asap. It is c++ program.
Home Activity
Consider the class class base
{
public:
virtual void iam0
{
cout << "base\n";
}
};
a.
Derive two classes from class base, and for each define iam() to write out the
name of the class.
b.
Declare objects of each class, and call iam) from them.
с.
Assign the address of objects of the derived classes to base pointers and call
iam() through the pointers.
d.
Remove the virtual keyword from the base class member function, run your code
again, and compare the results.
Develop a simple payroll application. There are three kinds of employees in the system:
salaried employee, hourly employee, and commissioned employee. The system takes as
input an array containing employee objects, calculates salary polymorphically, and
generates report.
Make Employee an abstract class. Declare salary) and display() as pure virtual
functions in it. Derive salaried employee (monthly), hourly employee (per hour basis), and
commissioned employee (bonus on completing each target) from base class Employee. The
display() function should show employee no, employee name, and salary of all employees.
Create a base class called shape. Use this class to store two double type values that could
be used to compute the area of figures. Derive two specific classes called triangle and
rectangle from the base shape. Add to base class, a member function get_data() to initialize
base class data members and another member functions display_area() to compute and
display the area of figures. Mark the display_area() as a virtual function and redefine this
function in the derived class to suit their requirements.(Use pure virtual function)
Transcribed Image Text:Home Activity Consider the class class base { public: virtual void iam0 { cout << "base\n"; } }; a. Derive two classes from class base, and for each define iam() to write out the name of the class. b. Declare objects of each class, and call iam) from them. с. Assign the address of objects of the derived classes to base pointers and call iam() through the pointers. d. Remove the virtual keyword from the base class member function, run your code again, and compare the results. Develop a simple payroll application. There are three kinds of employees in the system: salaried employee, hourly employee, and commissioned employee. The system takes as input an array containing employee objects, calculates salary polymorphically, and generates report. Make Employee an abstract class. Declare salary) and display() as pure virtual functions in it. Derive salaried employee (monthly), hourly employee (per hour basis), and commissioned employee (bonus on completing each target) from base class Employee. The display() function should show employee no, employee name, and salary of all employees. Create a base class called shape. Use this class to store two double type values that could be used to compute the area of figures. Derive two specific classes called triangle and rectangle from the base shape. Add to base class, a member function get_data() to initialize base class data members and another member functions display_area() to compute and display the area of figures. Mark the display_area() as a virtual function and redefine this function in the derived class to suit their requirements.(Use pure virtual function)
Expert Solution
steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,