This is the case of the most unpleasant parsing , where the compiler interprets A<B> a2(B(v)) as a function declaration. Such that:
A<B> is the return type
a2 is the name of the function
B is the type of argument
v is the name of the argument
So when you do
std::cout << a1.yu << " " << a2.yu << std::endl;
The compiler does not consider a2.yu as a class, so you get a non-class type error.
Also, since a double bracket is not allowed in a function declaration , version A<B> a2((B(v))); works because the compiler no longer interprets it as a function declaration, but as a variable declaration.
Mesop source share