BP> KK> friend ostream &operator<<(ostream&, const MathCalc&);
BP> KK> // This function is an ostream friend and has access to
BP> KK> // ostream functions. It returns an ostream object which
BP> KK> // is created within the friend function
BP> KK> ostream &operator<<(ostream &O, const MathCalc &MC)
BP> KK> {
BP> KK> // This function creates an ostream object. It accepts an
BP> KK> // ostream object and a data object. It then formats the
BP> KK> // data in the data object to an ostream format and returns
BP> KK> // the ostream to the calling function.
BP> KK> O << MC.iVar1 << " " << MC.cOperation << " " << MC.iVar2
BP> KK> << " = " << MC.iResult << "\n\r" << flush;
BP> KK> return O;
BP> KK> }
BP> The functions are correct but the comments aren't. The
BP> function does _not_ create a stream. (Nor it has to).
BP> It accepts a stream (by ref) as param and returnd that
BP> same stream.
In other words, it accepts a stream object and data, then
creates the desired ostream object from the data and
returns the ostream object. I regret that it may have been
misleading. I thought that it was clear enough that the
data was being formatted to create the desired object from
the given object. I'll get damage control on it. :)
> ] When I bend my fingers backward, I hear Satanic messages....
---
---------------
* Origin: *YOPS ]I[* 3.1 GIG * RA/FD/FE RADist * Milwaukee, WI (1:154/750)
|