Question
Using C++, Create a base class named Book. Data fields include title and author; functions include those that can set and display the fields. Derive
Using C++,
Create a base class named Book. Data fields include title and author; functions include those that can set and display the fields.
Derive two classes from the Book class: Fiction, which also contains a numeric grade reading level, and NonFiction, which contains a variable to hold the number of pages.
The functions that set and display data field values for the subclasses should call the appropriate parent class functions to set and display the common fields, and include specific code pertaining to the new subclass fields.
Write a test program that demonstrates the use of the classes and their functions.
Sample Run Book is Scarlet Letter by Hawthorne Reading level is 10 Book is Log Cabin Building by Landers 328 pages
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started