Is it possible to overload operators in C?

前端 未结 3 845
星月不相逢
星月不相逢 2020-12-19 01:32

Is it possible to overload operators (such as operators of comparison) in C?

If so, how do you do it? I did a quick search, but all I found was for C++, and what I

相关标签:
3条回答
  • 2020-12-19 02:01

    No, it is not possible. C does not support operator overloading by the developer.

    0 讨论(0)
  • 2020-12-19 02:13

    If by overload, you mean user defined operator overloads, then the answer is no. However, some of the predefined operators such as *, + etc. are overloaded (if you think about it) for arithmetic types. The * is special since it also has an overload for de-referencing pointers.

    0 讨论(0)
  • 2020-12-19 02:16

    C does not support overloading of operators or functions. There's no way you can redefine <, <=, >, >=, ==, or != to compare struct types directly.

    0 讨论(0)
提交回复
热议问题