Operator overload of << needs const; produces headache

前端 未结 4 1052
天命终不由人
天命终不由人 2021-01-24 21:54

I am trying to overload operator <<, but it always need to be a const function. However, I want to change values inside this overloaded function

4条回答
  •  时光取名叫无心
    2021-01-24 22:05

    operator<< doesn't need to be a const function.

    Your real problem, though, appears to be the void return type. In order to chain insertions together, you need to return *this.

提交回复
热议问题