Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hi, i want the program written in C++. ================================ Define a class Course with a print function (that prints I am a generic course). Define

hi, i want the program written in C++.

================================

Define a class Course with a print function (that prints I am a generic course).

Define a class Programming that publicly inherits the class Course with a print function (that prints I am Programming).

Define a class Physics that publicly inherits the class Course with a print function (that prints I am Physics).

Define a class Chemistry that publicly inherits the class Course with a print function (that prints I am Chemistry).

Define a class Mathematics that publicly inherits the class Course with a print function (that prints I am Mathematics).

Define a class NewCourse that publicly inherits the class Course with no member functions.

Run the program with the print function being a non-virtual function

Run the program with the print function being a virtual function

The following driver produces the given sample of output:

int main()

{

Course *aCourse[6];

aCourse[0] = new Course;

aCourse[1] = new Programming;

aCourse[2] = new Physics;

aCourse[3] = new Chemistry;

aCourse[4] = new Mathematics;

aCourse[5] = new newCourse;

for(int i = 0; i < 6; i++)

aCourse[i] -> print();

return 0;

}

Sample output:

With non-virtual print():

I am a generic course.

I am a generic course.

I am a generic course.

I am a generic course.

I am a generic course.

I am a generic course.

With virtual print()

I am a generic course.

I am Programming.

I am Physics.

I am Chemistry.

I am Mathematics.

I am a generic course.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions

Question

3. What might you have done differently?

Answered: 1 week ago

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago