Originally Posted by
pritin
#1 : SUPPOSE sum() returned a value, is it right to do
Code:
cout << sum(L1,L2).feet;
You mean, will that work? Sure. This would work too:
Code:
sum(L1, L2);
cout << L3.feet;
#2 How to print values of L3 in the original case, where sum() returns a reference to L3 case?
You mean, how would you print the previous value of L3 after sum() has modified it? You can't. That's why I don't like using global variables.
You'd have to save the value first:
Code:
distance prev = L3;
sum(L1, L2);
// L3 is the new
// prev is the old L3