For "cout", "<<" means output. For numbers, "<<" means Shift operations. For class, you can define it yourself.("cout" is a class witch define in the file "iostream.h")
<< 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
return lhs;
}
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.