struct X
{
X() { std::cout << \"X()\\n\"; }
X(int) { std::cout << \"X(int)\\n\"; }
};
const int answer = 42;
int main()
{
X(answer);
The parentheses are optional. What you said is identical to X answer;
, and it's a declaration statement.
nothing at all, because X(answer); could be interpreted as the declaration of a variable.
Your answer is hidden in here. If you declare a variable, you invoke its default ctor (if non-POD and all that stuff).
On your edit: To get a temporary, you have a few options:
If you want to declare a variable of the type X, you should do it this way:
X y(answer);