C++ error: cannot convert "unsigned int A::*" to "unsigned int*" in return
Dima Sorkin
dima.sorkin@gmail.com
Sun Oct 29 19:07:00 GMT 2006
On 10/28/06, Erik wrote:
> 3: unsigned int j() const throw () {return A::j;}
> 4: unsigned int * f() {return &A::j;}
> In member function "unsigned int* B::f()":
> cc_operators.cc:4: fel: cannot convert "unsigned int A::*" to "unsigned
> int*" in return
>
> If I change it to &(A::j) it works, but that should not be needed since
> operator:: has highest precedence according to the book, right?
>
Hi.
I don't know what exactly the C++ standard says and GCC thinks,
but I prefer to see the "&CLASSNAME::MEMBER" not as the
combination of parts "&" and "::", but as the whole, with the semantics
"give me a relative address of a member" .
This explains, why, in the second case, the "&(C::M)" should be used.
But better post this question to "comp.lang.c++.moderated".
Regards,
Dima.
More information about the Gcc-help
mailing list