C++ question:
Code:(3 object constructor initialize)
Song::Song()
{
}
Song::Song(const char song_name[MAX_SONG_NAME_LENGTH], int length_in_seconds)
{
strcpy(name,song_name);
length_in_seconds = length_in_seconds;
}
Song::Song(const char song_name[MAX_SONG_NAME_LENGTH], int minutes, int seconds)
{
strcpy(name,song_name);
minutes = minutes;
seconds = seconds;
}
Question: how to implement operator << to have such out put
, length: 0m 0s
All Star, length: 3m 20s
Take On Me, length: 3m 45s
main function:
Song s00{};
Song s01{"All Star", 200};
Song s02{"Take On Me", 3, 45};
cout << s00 << endl;
cout << s01 << endl;
cout << s02 << endl;