Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 using namespace std;

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 <songname=songname; this->singer =singer; this->time =time; min= time/60; sec= time-(min*60); }

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

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

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago