Why overload true and false instead of defining bool operator?

前端 未结 4 1854
孤城傲影
孤城傲影 2021-02-01 06:31

I\'ve been reading about overloading true and false in C#, and I think I understand the basic difference between this and defining a bool operator. The example I see around is

4条回答
  •  無奈伤痛
    2021-02-01 07:24

    Depending on the system, true can be any non-zero value. In others, it can be any positive value.

    Other systems aren't truly boolean, and allow a third state null or nill for the boolean values, which is why you might overload true and false, versus overloading a single bool operator.

提交回复
热议问题