#include #include #include using namespace std; class Song { public: void SetNameAndDuration(string songName, int songDuration) { name = songName; duration = songDuration; } void PrintSong() const { cout << name << " - " << duration << endl; } string GetName() const { return name; } int GetDuration() const { return duration; } private: string name; int duration; }; int main() { vector songPlaylist; Song currSong; string currName; int currDuration; unsigned int i; cin >> currName; while (currName != "quit") { /* Your code goes here */ } for (i = 0; i < songPlaylist.size(); ++i) { currSong = songPlaylist.at(i); currSong.PrintSong(); } return 0; }

Respuesta :

Answer:

Check the explanation

Explanation:

#include <iostream>

#include <string>

#include <vector>

using namespace std;

class Song {

public:

   void SetNameAndDuration(string songName, int songDuration) {

       name = songName;

       duration = songDuration;

   }

   void PrintSong() const {

       cout << name << " - " << duration << endl;

   }

   string GetName() const { return name; }

   int GetDuration() const { return duration; }

private:

   string name;

   int duration;

};

int main() {

   vector<Song> songs;

   Song currentSong;

   string currentName;

   int currentDuration;

   unsigned int i;

   cin >> currentName;

   while (currentName != "quit") {

       cin >> currentDuration;

       Song temp;

       temp.SetNameAndDuration(currentName, currentDuration);

       songs.push_back(temp);  

       cin >> currentName;

   }

   for (i = 0; i < songs.size(); ++i) {

       currentSong = songs.at(i);

       currentSong.PrintSong();

   }

   return 0;

}