Question: Need help with the following c++ lab that involves polymorphism and inheritance Polymorphism Lab (Library Holdings) In this assignment you will learn how to use
Polymorphism Lab (Library Holdings) In this assignment you will learn how to use inheritance and virtual functions by designing a set of classes to represent library holdings. Our library has two kinds of items: books and recordings. Each item has a title and an integer call number In addition, books have authors, and recordings have performers and formats In addition to constructors and destructors, each holding WAV, FF). (MP3 function that displays its data to an ostream object should have a pr (such as cout) that the user specifies You should begin by designing a Holding class that contains all the data common to books and recordings. It should also have a pure virtual print function. Then design the Book and Recording classes to add the details necessary for those types of items and to implement the print function. Note that Holding will be an abstract base class, since it will have a pure virtual function. This makes sense, since there are no generic holdings, only books and recordings accept classes should have both copy constructors and constructors that to the individual data fields as arguments. Although it may seem natural have a zero-argument default constructor that the user and reads in the data fields, doing I/O from within a constructor is probably unwise. If the constructor did class implementation would be tied to a particular style of getting data. Applications that use this class may read input from a which the prompt messages would be inappropriate, or they may a window- based interface that does not support the cin and cout I/O stream objects. Since constructors are such a basic part of the operation of a class, it is best to let the user decide where their input data comes from Once you have written the code to implement the Holding, Book, and Recording classes, you should write a simple program to test them. This program should declare an array of five pointers to Holding objects and then repeatedly call a function that creates a new Holding. This function asks the user which kind of Holding is to be entered and then inputs the data needed to a Book or a Recording. A new object of the appropriate class i create either created with this data, and the resulting pointer is returned. a Book pointer or a Note that even though the function always returns either Recording pointer, the function can be declared to return a Holding pointer, and the pointer to the newly created object can be returned without conversion. This pointer is then stored in the array and the function is called again until all Page 504 Focus on Object-oriented Programming with C++
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
