J
Jess
Hello,
If I have a statement
A a(B());
where A and B are both types, then it seems I can have two
interpretations:
1. B() is a casting operation and returns an object of type B, which
is then passed to A's constructor (taking a B object as argument) to
construct an A object. Hence the statement is a definition, defining
an object "a" of type A.
2. B() is the same as B(*)(), hence the statement is a function
declaration: "a" is a function, which takes a pointer to a function
(the function takes no arg and returns a result of type B) and returns
an object of type A.
Both seem reasonable, but which one of them is correct?
Similarly, a statement
A a(B (c));
also seems to have two interpretations, since I can either interpret
"B (c)" as a casting operation, or a pointer to a function.
I vaguely remember that the Standard says if a statement can be
interpreted as a declaration, then it is a declaration. If so, I
guess the statements above are declarations.
Thanks a lot,
Jess
If I have a statement
A a(B());
where A and B are both types, then it seems I can have two
interpretations:
1. B() is a casting operation and returns an object of type B, which
is then passed to A's constructor (taking a B object as argument) to
construct an A object. Hence the statement is a definition, defining
an object "a" of type A.
2. B() is the same as B(*)(), hence the statement is a function
declaration: "a" is a function, which takes a pointer to a function
(the function takes no arg and returns a result of type B) and returns
an object of type A.
Both seem reasonable, but which one of them is correct?
Similarly, a statement
A a(B (c));
also seems to have two interpretations, since I can either interpret
"B (c)" as a casting operation, or a pointer to a function.
I vaguely remember that the Standard says if a statement can be
interpreted as a declaration, then it is a declaration. If so, I
guess the statements above are declarations.
Thanks a lot,
Jess