This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: C++ error: cannot convert "unsigned int A::*" to "unsigned int*" in return
- From: "Dima Sorkin" <dima dot sorkin at gmail dot com>
- To: Erik <sigra at home dot se>, gcc-help at gcc dot gnu dot org
- Date: Sun, 29 Oct 2006 21:07:15 +0200
- Subject: Re: C++ error: cannot convert "unsigned int A::*" to "unsigned int*" in return
- References: <4543914B.6090803@home.se>
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.