operator+
combines the data of two input objects (in your example, the left-hand object is *this
) and returns a new object containing the combined data.
operator>>
(and operator<<
) returns a reference to the stream that is being acted on. This allows for chaining multiple stream operations, eg:
cin >> var1 >> var2 ...;
// which is the same as:
// cin.operator>>(var1).operator>>(var2) ...
// or:
// operator>>(operator>>(cin, var1), var2) ...
// etc, depending on the particular types and operator overloads being used
cout << var1 << var2 ...;
// which is the same as:
// cout.operator<<(var1).operator<<(var2) ...
// or:
// operator<<(operator<<(cout, var1), var2) ...
// etc, depending on the particular types and operator overloads being used
Without being able to chain, stream operations would have to be called individually instead, eg:
cin >> var1;
cin >> var2;
...
cout << var1;
cout << var2;
...