← Back to Classes
Question 79
Playlist Track Access (const and non-const operator[])
Playlist Track Access (const and non-const operator[])
You are managing a tiny playlist of 3 song titles. Create a class Playlist with a private array of 3 strings. Requirements: 1) Constructor Playlist(string a, string b, string c) 2) Overloadoperator[]in TWO ways: - string&operator[](int index) (non-const) - const string&operator[](int index) const Do NOT write a main function.
Expected Output:
Focus Deep Work
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
ClassesOperator Overloading
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.