How can I set up the operator<< function to allow me to stream data into cout (or any other ostream)?
The way you did here:
std::ostream& operator<<(std::ostream& os, const T& obj)
{
// write obj to stream
return os;
}
As others usefully pointed out in the comments, you will need to place it outside of your integer classes to be a "free function". It could still be the member of your integer classes, but yeah, that is it.
But this seems to be for if I wanted to stream something into my object. (i.e. having the << on the right side of my object). But I want to change the behavior of << when it is on the LEFT side of my object.
I am not sure where you got that from but the first argument is the left side argument which is the output stream in your case, and the second is the instance of your integer class that gets written to that output stream.