What makes Scala's operator overloading “good”, but C++'s “bad”?

后端 未结 14 2078
悲哀的现实
悲哀的现实 2020-12-12 11:20

Operator overloading in C++ is considered by many to be A Bad Thing(tm), and a mistake not to be repeated in newer languages. Certainly, it was one feature specifically drop

14条回答
  •  一生所求
    2020-12-12 12:06

    Operator overloading is not something that you really "need" very often, but when using Java, if you hit a point where you genuinely need it, it'll make you want to rip your fingernails out just so you have an excuse to stop typing.

    That code which you've just found overflows a long? Yup, you're going to have to retype the whole lot to make it work with BigInteger. There is nothing more frustrating that having to reinvent the wheel just to change the type of a variable.

提交回复
热议问题