The code
B b(A());
is not declaring an object of B
, but rather a function declaration for a function b
which returns an object of type B
and takes a single (unnamed) argument which is a function returning type A
(and taking no input). (Quoting from link below). Therefore, you saw that error.