Two strings between brackets separated by a comma in C++

Viewed 1732

I came across unexpected (to me at least) C++ behavior today, shown by the following snippit:

#include <iostream>

int main()
{
  std::cout << ("1", "2") << std::endl;

  return 0;
}

Output:

2

This works with any number of strings between the parentheses. Tested on the visual studio 2010 compiler as well as on codepad.

I'm wondering why this compiles in the first place, what is the use of this 'feature'?

5 Answers
Related