-
Notifications
You must be signed in to change notification settings - Fork 7
Description
The continuation of a paragraph started on the previous page (21) descries the following line of code:
Product p2(Box());
as following:
Similarly, the line with p2 also causes errors.
This time the compiler thinks we declare a local function p2 returning a Product and taking
Box as an argument (Box() is treated as Box(*)(), which is a function declaration called
Box that takes no arguments and returns void).
I think the error here is that you correctly describe how the Box() is treated as Box(*)() but
then incorrectly interpret it in writing as "...which is a function declaration called Box that takes
no arguments and returns void."
Box(*)() is not a function called Box with no arguments and returning void.
It is an unnamed parameter with the type of a pointer to a function which does not take parameters
and which returns an object of type Box.
Please see item 2 of section "Unnamed temporary" at https://en.wikipedia.org/wiki/Most_vexing_parse
The error in this case will be "'Box' was not declared in this scope" which means the compiler is looking
for a type definition for the Box as a return type.