[LC++]Overlading << to input into my class

David Filion filiond at videotron.ca
Wed Nov 28 11:43:12 UTC 2001


First some info.  Here is an outline of the class I'm creating...

class Log {
private:
	ofstream outfile;
	// Other members..
public:
	// Constructors, destructors here
	// Other methods here..
};

I would like to overload the << operator so I can do the following:
mylog << "so text";

For example:

main ()
{.
	Log mylog ("somename");
	// ... Do some other stuff ...

	mylog << "message to be sent to outfile member of mylog" << endl;
}


All the references on overloading << I've come accrss refer to setting up
<< as a friend 
so I can output my class to cout.  I want to output the provided text to
the outfile member of
the Log class along with some other info.

Thanks.





More information about the tuxCPProgramming mailing list