Home > Back-end >  Why can't overload
Why can't overload

Time:10-12

I see the video but can't write so! V

CodePudding user response:

Estimate is that the rear + + returns a temporary MyInt, since then the original MyInt increases, then the makeshift MyInt as a parameter to the overloaded function to print, because of the overloaded function parameter is a reference type, and temporary variables can not quote, so wrong,

CodePudding user response:

Hey hey, little brother and I used to like, this is because the rear + + overloading to add an int in the parameter list do a placeholder, for the difference between front rear + + and + +, and rear + + return without a copy of the front
+ + returns have to add a reference itself,

CodePudding user response:

Here you overload & lt; CodePudding user response:

Remember to add const

CodePudding user response:

+ + returned temporary objects and functions you accept is a const reference
  • Related