Question: 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

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 Databases Questions!