Default constructor with empty brackets
Most vexing parse
This is related to what is known as "C++'s most vexing parse". Basically, anything that can be interpreted by the compiler as a function declaration will be interpreted as a function declaration.
Another instance of the same problem:
std::ifstream ifs("file.txt");
std::vector<T> v(std::istream_iterator<T>(ifs), std::istream_iterator<T>());
v
is interpreted as a declaration of function with 2 parameters.
The workaround is to add another pair of parentheses:
std::vector<T> v((std::istream_iterator<T>(ifs)), std::istream_iterator<T>());
Or, if you have C++11 and list-initialization (also known as uniform initialization) available:
std::vector<T> v{std::istream_iterator<T>{ifs}, std::istream_iterator<T>{}};
With this, there is no way it could be interpreted as a function declaration.
Because it is treated as the declaration for a function:
int MyFunction(); // clearly a function
MyObject object(); // also a function declaration
The same syntax is used for function declaration - e.g. the function object
, taking no parameters and returning MyObject