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;
}