"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:U_DGb.39324$VB2.79533@attbi_s51
"Dave" <be***********@yahoo.com> wrote... [...]
Another interesting point: Suppose I change the definition of r to
the following:
const base &r(derived());
In this case, I get no output at all!
Not sure what's going on with all of this...
const base& r(derived());
is a declaration of a function 'r' that takes one argument of type
'derived' and returns a reference to const base. Internal parens
do not matter.
Victor
VC++ 2002 doesn't interpret it that way (it treats it as an assignment to r)
but I presume that this is just a bug.
Comeau online, by contrast, does treat it as a function declaration, but
interprets the function's parameter as a pointer to a function that takes no
parameters and returns a derived object. Thus the following compiles:
derived foo()
{
derived d;
return d;
}
int main()
{
const base &r(derived());
r(foo);
}
whereas the following fails with the error message:
error: no suitable conversion function from "derived" to
"derived (*)()" exists
int main()
{
const base &r(derived());
derived dobject;
r(dobject);
}
I don't know if this is a bug or if there is some way in which a parameter
of type
derived()
can legitimately be intepreted as a parameter of type
derived(*)().
--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)