Overloading operator << - C++

后端 未结 7 1655
Happy的楠姐
Happy的楠姐 2021-02-10 07:25

Background

I have a container class which uses vector internally. I have provided a method AddChar(std::string) to this wrap

7条回答
  •  孤独总比滥情好
    2021-02-10 08:23

    Is it a good practice to overload operators in situations like this?

    I don't think so. It's confusing as hell for someone who doesn't know that you've overloaded the operator. Just stick to descriptive method names and forget about the extra characters you're typing, its just not worth it. Your maintainer (or you yourself in 6 months) will thank you.

提交回复
热议问题