I recently wondered where string
overloads the +
-operator. The only methods i can see are ==
and !=
. Why can two strings be concatenated with + even if that operator is not overloaded? Is this just a magic compiler trick or am i missing something? If the former, why was string designed in that way?
This question was raised from this. It's difficult to explain someone that he cannot use +
to concatenate two objects since object
does not overload this operator if string
does not care about overloading operators either.