Question: C++ constructor and keyword new add a constructor to the Song class that takes no parameters and sets all fields to appropriate default values. Next
C++ constructor and keyword new
add a constructor to the Song class that takes no parameters and sets all fields to appropriate default values.
Next change the provided code in main so that all Song objects are allocated using the keyword new and the constructor you just created.
Finally, after a song is played in main, delete it.
#include
class Song{ string songname; string singer; int time; int sec; int min; public: string play (Song); Song(string songname, string singer, int time); void play(){ cout << "Played \"" << songname <<"\" by " << singer << " for " << min <<":" << sec <
int main(int argc, char **argv) { Song s1("Black Hole Sun", "SoundGarden", (3*60)+41); Song s2("Nevermind", "Nirvana", (2*60)+56); Song s3("GrandHotel", "Regina Spektor", (3*60)+50);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
