Your operator+= takes it's arguments by value (copy) and returns a copy so when you type k1+=k2 you copy k1 and k2 and return a copy, that you don't capture (put into a variable). This means that k1 and k2 haven't been modified since you passed by value, which results in k1 retaining the same value.