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

前端 未结 3 783
渐次进展
渐次进展 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:44

    No we cannot overload integer or float types because overloading means to change the working of existing operators or make them to work with objects int is single member not an object.

提交回复
热议问题