Consider the following code
struct A {
A() { /* do something */ }
};
struct B {
B(const A& a) { /* do something*/ }
};
int main() {
B b(A());
// the rest of the code
}
So I intended to define b
as a variable constructed from a temporary instance of A
. However, compiler comprehends this line as a function prototype declaration:
warning C4930: 'B b(A (__cdecl *)(void))': prototyped function not called (was a variable definition intended?)
Can someone explain what's going on and how to do what I intended? Is this some known ambiguity resolved by the standard towards a function prototype rather than variable definition?
I know B b = A();
works, however, I don't like how it looks. It doesn't show the intent.