Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I posted the instructions and the example output. We now want make the songmain.cpp file more dynamic in how many song entries to create. Note

I posted the instructions and the example output. image text in transcribed
image text in transcribed
image text in transcribed
We now want make the songmain.cpp file more dynamic in how many song entries to create. Note that we don't want a fixed array size; we want to only allocate enough memory for the exact number of entries we have. So first your program should ask the user how many song entries they would like to add. Then the program should create an array of Song objects of exactly that size To create a dynamic array, start by declaring the array as a pointer Song* list; Then create the array of Song objects after asking the size of the array: list new song [size]; Then use a for loop to ask for the information for each song. Then you will need to call the setters for each field (title, artist, year and duration) to set the values in the Song object Now, again using another for loop, print out each song entry in the list using the print function. When done printing, remember to delete the list: delete [1 list; Make C-strings dynamic inside Song class To make the program fully dynamic, we should also create the C-strings dynamically. Start by changing the title and artist member variables to pointer to char char title; // and so on... Then in the constructor, set these to NULL. This will help determine if these have been previously set to a value. title nullptr; // and so on... Now, in the getters, we don't need to copy into a passed in C-string; we can now pass back the pointer to the C-string. To be on the safe side, use the const keyword in the return type

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

0262660709, 978-0262660709

More Books

Students also viewed these Databases questions

Question

1. Is this appropriate?

Answered: 1 week ago

Question

13-4 What are alternative methods for building information systems?

Answered: 1 week ago