Examples of Stream I/O
cout << "n " << n << " m " << m << " average " << (n+m)/2.0 << '\n';
Easy to provide formatting capabilities for a new data type.
ostream & operator << (ostream & out, const rational & value) { // print representation of rational number on an output stream out << value.numerator() << '/' << value.denominator(); return out;
cout << "fraction of " << 3 << " and " << 4 << " is “