Question: #include #include using namespace std; class Song { private: string title; string artist; int year; public: Song(); Song(string title, string artist, int year); bool operator==(Song&
#include #include using namespace std;
class Song { private: string title; string artist; int year; public: Song(); Song(string title, string artist, int year);
bool operator==(Song& s1);
bool operator
friend std::istream& operator>>(std::istream& din, Song&);
friend std::ostream& operatortitle = title; } void Song::set_artist(string artist) { this->artist = artist; } void Song::set_year(int year) { this->year = year; }
Song::Song() : title("invalid") , artist("invalid") , year(-1) { } Song::Song(string title, string artist, int year) : title(title) , artist(artist) , year(year) { } string Song::get_title() { return title; } string Song::get_artist() { return artist; } int Song::get_year() { return year; } istream& operator>>(std::istream& cin, Song& s) { cout > s.title; cout > s.artist; cout > s.year;
return cin; } ostream& operator
}
bool Song::operator==(Song& s1) { return artist.compare(s1.artist) == 0 && title.compare(s1.title) == 0 && year == s1.year; } bool Song::operator
int main() {
Song s1("Radioactive", "ImagineDragons", 2012); cout
Song s2; cin >> s2; cout
if (s1
return 0; }

test sample file:
FreakingOut MysterySkulls 2015 Fancy IggyAzalea 2014 ThisIsAmerica DonaldGlover 2018
3. (36%) Create a program that reads a file containing a list of songs and prints the songs to the screen one at a time. After each song is printed, except for the last song, the program asks the user to press enter for more. 1 After the last song, the program should say that this was the last song and quit. If there were no songs in the file to begin with, the program should say that there are no songs to show and quit. The program should begin by asking the user for the name of the input file. Each song consists of a title, artist and year, as described in Assignment 1. In the file, each song is given on three consecutive lines, also as described in Assignment 1. Create this program using the class Song from the first exercise of this assignment. Organize your program into separate files as explained in Section 2.4 of the notes
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
