Topic: Can Default parameters use other paramters values?
Author: nbecker@fred.net
Date: 1999/08/11 Raw View
In short, is code of this sort legal?
int func (int a, int b, int c = b - a);
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Darin Adler" <darin@bentspoon.com>
Date: 1999/08/11 Raw View
nbecker@fred.net wrote:
> In short, is code of this sort legal?
>
> int func (int a, int b, int c = b - a);
In short, no.
-- Darin
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Hyman Rosen <hymie@prolifics.com>
Date: 1999/08/11 Raw View
nbecker@fred.net writes:
> In short, is code of this sort legal?
> int func (int a, int b, int c =3D b - a);
8.3.6 9 explicitly says no.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: wmm@fastdial.net
Date: 1999/08/11 Raw View
In article <x88g11t6ja0.fsf@rpppc2.hns.com>,
nbecker@fred.net wrote:
> In short, is code of this sort legal?
>
> int func (int a, int b, int c = b - a);
No. 8.3.6p9: "The order of evaluation of function arguments is
unspecified. Consequently, parameters of a function shall not
be used in default argument expressions..."
--
William M. Miller, wmm@fastdial.net
Software Emancipation Technology (www.setech.com)
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]