In C++ every expression that looks like a function declaration is a declaration of a function. Consider more complex sample that in your question:
#include <iostream>
struct X
{
X( int value ) : x(value) {}
int x;
};
struct Y
{
Y( const X& x ) : y(x.x) {}
int y;
};
int main()
{
int test = 10;
Y var( X(test) ); // 1
std::cout << var.y << std::endl; // 2
return 0;
}
At first glance (1) is a declaration of the local variable var
which should be initialized with a temporary of a type X
. But this looks like a function declaration for a compiler and you will get an error in (2):
error: request for member ‘y’ in ‘var’, which is of non-class type ‘Y(X)’
The compiler considers that (1) is the function with name var
:
Y var( X test );
^- return value ^-function name ^-type of an argument ^-argument name
Now, how to say to the compiler that you do not want to declare a function? You could use additional parentheses as follows:
Y var( (X(test)) );
In your case MainGUIWindow myWindow()
for the compiler looks like function declaration:
MainGUIWindow myWindow( void )
^- return value ^-function name ^-type of an argument