Overloading += in c++
问题 If I've overloaded operator+ and operator= do I still need to overload operator+= for something like this to work: MyClass mc1, mc2; mc1 += mc2; 回答1: operator+= is not a composite of + and =, therefore you do need to overload it explicitly, since compiler do not know to build puzzles for you. but still you do able to benefit from already defined/overloaded operators, by using them inside operator+=. 回答2: Yes, you need to define that as well. A common trick however, is to define operator+= ,