In the code above, the compiler will assign 10 to whatever is returned from mymap.
std::map<int, int> mymap;
mymap = 10; // What would happen here if mymap returns, say, char*?
So if mymap returned char* instead of int&, what would happen? Compile error, and not something you'd expect!
And if it merely returned int, the you would assign to a temporary!
In other words, you don't make any change in the map at all.
And please, write the class the right way
int& operator (int index)
if (index < maxSize)