<< is a bitwise left shift operator. It is overloaded to work differently with ostream and derived classes. Standard library provides overloads fo all built-in types and several calsses from standard library (std::string for example). You can also provide overload for your own classes.
Typical overload looks like:
1 2 3 4 5
std::ostream& operator<<(std::ostream& lhs, T const& rhs)
//Do output here
Where T is your type.
You need to return stream to allow for operator chaining. Suppose you have following code:
std::cout << "x" << 2;
As operator << has left-to-right associativity, it could be imagined as:
operator<<( operator<<(std::cout, "x"), 2);
Result of inner operator<< call is std::cout, so outer one will work fine.