This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ error: cannot convert "unsigned int A::*" to "unsigned int*" in return


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]