@Ghettoburger,
(EDIT - have you just removed a post? I'm replying to it here.)
I assembled a structure (here, called THING) to hold a collection of related items of different types. It's probably not precisely what you want (you probably need more integers), but you should get the gist. It's basically a user-defined type. There is more about such things in the excellent tutorial on this site:
http://www.cplusplus.com/doc/tutorial/structures/
Now, suppose I want to write just one of those structures to a file - more specifically, in C++ I write to a stream that is connected to a file. You can find a lot about it here:
http://www.cplusplus.com/doc/tutorial/files/
It is convenient to write a routine that will work for ANY output stream (an
ostream), even the standard cout if I wanted. So I could just do this through a function declared as
void output( ostream &strm, THING thing )
and it will be called from main() as just
output( out, thing);
In fact that is precisely what I did at first - but I didn't post it. However, all this routine does is write one THING to file. If I was to write a single integer N to this output stream I would probably write
out << N;
So all I have done with the routine that you highlight is allow me to do the same for my user-defined type instead of an integer:
out << thing;
The posh name for this is
overloading the insertion operator (you can google that phrase) - I am basically writing a routine allowing the normal << operator to work for my own type; without it the system wouldn't know what to do.
If you want to change the line in main() to
cout << thing;
then you will find that the output can go to the normal screen output stream instead of to file. Try it.
I have been told on this forum that overloading operators is too much for beginners. However, I personally think that overloading << (and >>) is quite useful for user-defined types and makes for easier syntax further down the line.
I hope that helps.