I have a use case
If I have 5 classes A,B,C,D,E and their instances as a,b,c,d,e
If there is an expression
a = b + c + d + e;
What is the order of invocation of operator+ and operator=.
Also what would be the temporary object created.
Can you please help me
+is left associative.=is right associative. The order would bed+emakes a temporarydede+cmakes temporarycde. This is done by a call to classC‘s operator+taking an argument of whatever class the temporarydeis an instance of.cde+bmakes temporarybcde. This is done by a call to classB‘s operator+taking an argument of the class ofcde.bcdeis assigned to variablea.Temporaries here are a general case, it depends on what you actually do with your overload what will happen. The class to the left of the temporary will be called using that temporary as an argument, not the other way around.
While the evaluation goes from left to right when using
+, the actual computation goes the other way.