Topic: Work-around for ambiguous declaration
Author: David R Tribble <david.tribble@central.beasys.com>
Date: 1997/03/19 Raw View
James Kanze <james-albert.kanze@vx.cit.alcatel.fr> wrote:
> B myB( A() ) ;
>
> According to the CD, this declares a function taking a pointer to an A
> and returning a B.
fjh@murlibobo.cs.mu.OZ.AU (Fergus Henderson) replied (correctly):
> Don't you mean "this declares a function taking a (pointer to) a
> function [taking no arguments and returning an A] and returning a B"?
Fergus also suggested a solution to the question:
> > Given this, how does one go about defining a B
> > initialized with an explicitly constructed A?
>
> How about
> B myB( (0, A()) ) ;
My suggestion is to use a [outdated] feature of the language to
disambiguate the syntax:
auto B myB(A());
I can't help mentioning that if C++ required identifiers on function
parameter prototypes, this sort of ambiguity wouldn't exist.
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]