Can we overload operators for built-in types like int or float?

前端 未结 3 789
渐次进展
渐次进展 2020-11-27 07:34

Can we declare a function like this in c++:

int operator + (int , int);

Your answers will be appreciated!

Thanks

3条回答
  •  误落风尘
    2020-11-27 07:41

    Yes: You can pass ints and floats into overloaded functions

    No: You cannot overload/override the operators for built in types when the built-in types are on both sides of the expression.

提交回复
热议问题