operator<< for Playlist
mediumQuestion 636A class Playlist holding a vector<string> of song names is given, together with a friend declaration for operator<<. Define the free function ostream& operator<<(ostream& os, const Playlist& p) below the class so that a playlist prints as the word Playlist, the number of songs in parentheses, a colon, a space, and then the song names separated by a comma and a space. Print no newline; return os.
A playlist with songs a, b, c prints the output shown in Expected Output.
An empty playlist prints only Playlist(0): with nothing after the colon (no trailing space).
Do NOT write a main function.
Expected output
Playlist(3): a, b, c Playlist(0): Playlist(1): solo
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Streamsostream
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.