Question: Please help me with this entire C++ Lab example. thank you so much Polymorphism Lab (Library Holdings) represent library holdings. Our library has two kinds

Please help me with this entire C++ Lab example. thank you so much

Please help me with this entire C++ Lab example. thank you so

much Polymorphism Lab (Library Holdings) represent library holdings. Our library has two

Polymorphism Lab (Library Holdings) represent library holdings. Our library has two kinds and recordings. Each item has a title and an integer call number In this assignment, you will learn how to use inheritance and virtual functions by designing a set of classes to of items: books In addition, books have a (MP3, WAV, AIFF). In addition to constructor uthors, and recordings have performers and formats s and destructors, each holding should have a print() function that displays its data to an ostream object (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 All three classes should have both copy constructors and constructors that accept the individual data fields as arguments. Although it may seem natural to have a zero-argument default constructor that queries the user and reads in the data fields, doing I/O from within a constructor is probably unwise. If the constructor did /O, the class implementation would be tied to a particular style of getting data. Applications that use this class may read input from a file, in which case the prompt messages would be inappropriate, or they may use a window based interface that does not support the cin and cout /O stream objects. ince 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 create either a Book or a Recording. A new object of the appropriate class is created with this data, and the resulting pointer is returned. Note that even though the function always returns either a Book pointer or a 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 al Focus on Object-Oriented Programming with C++ Page 5

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!