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.
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.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 12RQ
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)](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F9f7552ad-35a2-48d4-ba57-835f9f48dc9b%2Fd27b9bed-4737-4422-8cb8-b90d68b0b49b%2Fr8baeri_processed.jpeg&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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.Recommended textbooks for you
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,