Question: C++ Polymorphism 1) Create a base class Publication with these members: protected variable title (string) pure virtual function showData() constructors and additional functions as needed
C++ Polymorphism 1) Create a base class Publication with these members: protected variable title (string) pure virtual function showData() constructors and additional functions as needed Create three classes derived from Publication, with these members: Book with variable pages (int) Video with variable resolution (char[2]) Music with variable format (enum data type) Book, Video, and Music all have virtual function showData() Write a main program which Creates an array of pointers to six Publication objects. Initializes this array with hard-coded data for two Books, two Videos, and two Music objects. Using showData(), displays data for all six objects. Your display should look like this: Type Title Other ---- ----- ----- Book War and Peace 908 Book Harry Potter 324 Video Dunkirk HD Video Toy Story Lo Music Someone Like You MP3 Music Happy WAV Your code must demonstrate polymorphism.
2) Modify your code to display data in this format: Type Title Pages Resolution Format ---- ----- ----- ---------- --------- Book War and Peace 908 - - Book Harry Potter 324 - - Video Dunkirk - HD - Video Toy Story - Lo - Music Someone Like You - - MP3 Music Happy - - WAV If you cannot find a simple, polymorphic way to code this, explain why not.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
