In this example, you are returning a link to total , which allows us to use the expression total.combine(trans) as a modified total object.
For example, if operator<< overloaded for Sales_data , we can simply combine and print the modified totals as follows:
std::cout << total.combine(trans);
or we can bind methods if we want to combine many times for the same object:
total.combine(trans).combine(trans1);
In this example, total merged, and the same total object is returned, and we can again merge with the already modified object.
This is a good template to simplify the code when you need to use a modified object in the same expression.
source share