B var = A();
B(A&&) explicit ( , ).
B var(A{});
.
The compiler believes that your original line is a function declaration, because in C ++ you can declare everything locally, even functions or structures:
int f()
{
void f();
class C;
}
In your case:
B var(A());
The compiler sees that there is a function with a name varthat returns Band receives a function that takes no parameters and returns A.
You must eliminate this using either of the two approaches presented above.
source
share