Topic: Defining object in function call
Author: clamage@Eng.Sun.COM (Steve Clamage)
Date: 1996/01/16 Raw View
ray@cse.ucsc.edu (Ray Swartz) writes:
>I read somewhere (this newsgroup, I think) that the limitation on
>defining variables/objects in function calls had been lifted.
>I tried to find this in the April WP but failed.
If you mean something like
void foo(int);
main()
{
foo(int i = 12); // valid?
that has never been allowed as a function call. (The example is
a valid construct, but it re-declares 'foo' to have a default
argument of value 12. It is not a function call.)
This example shows one reason why it isn't allowed: ambiguity.
A function call contains a list of expressions, and an expression
cannot contain a variable definition. (The "condition" part of a
selection statement or loop may now contain a variable definition,
but those are not expressions.)
--
Steve Clamage, stephen.clamage@eng.sun.com
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]