结果导致C ++运算符超载('+','+ =') [英] C++ operators overloaded as a consequence ('+', '+=')
本文介绍了结果导致C ++运算符超载('+','+ =')的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我重载时,可以说C ++类的'+'运算符
When I overload, lets say, the '+' operator for a class in C++
MyClass MyClass::operator+(MyClass _c){
//code here
}
它是否自动应用于'+ ='运算符?编译器是否会自动将其替换为较长的计算机部件(a + = b<-> a = a + b)?还是运行时运算符功能?
Does it automatically apply to the '+=' operator? Does the compiler automatically substitute that for its longer conuterpart (a+=b <--> a=a+b)? Or is it a runtime operator function?
推荐答案
否.没有.您还需要使它们超载.
No. It doesn't. You need to overload those as well.
这篇关于结果导致C ++运算符超载('+','+ =')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文