How does logical negation work in C?

前端 未结 5 955
春和景丽
春和景丽 2020-12-03 11:47

I have been using ! (logical negation) in C and in other languages, I am curious does anyone know how to make your own ! function? or have a creative way of making one?

5条回答
  •  猫巷女王i
    2020-12-03 12:24

    If you want to overload an operator, the proper prototype is:

    bool operator!();
    

    I'm not a big fan of overloading operators, but some people like their syntactic sugar. EDIT: This is C++ only! Put it in the definition of your class.

提交回复
热议问题