Question: c + + . A ) Define a Book class with data members for title, author, and publication year. Include a virtual function named displayInfo

c++.A) Define a Book class with data members for title, author, and publication year. Include a virtual function named displayInfo() that prints out the book's title, author, and publication year. Create two derived classes, Fiction and NonFiction, that add data members for genre and subject, respectively. Override the displaylnfo() function for each derived class to include the additional data members. Demonstrate polymorphism by creating an array of Book pointers, filling it with Fiction and NonFiction objects, and calling the displaylnfo() function for each.
B) Explain how Book class can be converted into an abstract class and what are the advantages of using an abstract class in Book scenarios.
How a Book class object can|access the Fiction class members? Write sample code for that?
Note: Definition of the member function should be outside of the class
Note: You must add required member functions or data members/variables in your program to complete its execution. use c++
c + + . A ) Define a Book class with data members

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