It should be noted that the << operator (with respect to std::cout) does not mean exactly "separate variables from literal stuff" but rather to write the right-hand side to the left-hand side (being stdout in this case).
In a more general sense, the joining of strings is called concatenation, and std::string (like the string classes in various other languages) defines the + operator for this purpose:
Code:
std::cout << "Hi, my name is " + name + " and I'm using " + language + "." << std::endl;
Note that this cannot be applied to two operands which are string literals, because the string literal represents a char array and not a std::string object:
Code:
$ cat test2.cpp
#include <string>
int main()
{
std::string test = "Hello " + "World";
return 0;
}
$ g++ test2.cpp -o test2
test2.cpp: In function ‘int main()’:
test2.cpp:5: error: invalid operands of types ‘const char [7]’ and ‘const char [6]’ to binary ‘operator+’
In this respect, the << operator is nice because it accepts anything that has a string representation.