This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: public method hidden by protected one
- From: John Love-Jensen <eljay at adobe dot com>
- To: Francois Coulon <francois dot coulon at gmail dot com>
- Cc: MSX to GCC <gcc-help at gcc dot gnu dot org>
- Date: Mon, 26 Nov 2007 07:11:48 -0600
- Subject: Re: public method hidden by protected one
Hi François,
> But why should this prevent from calling a const method ?
Because it's a non-const pointer, and there is a non-const method which is
an exact unambiguous signature match, and that non-const method has
protected accessibility.
Add a const_instance method that returns a const pointer, and then use that.
Or don't overload the same method name with different accessibility.
Or don't overload the same method name at all, rather have different named
methods. (This is the option that I think is best, because it is obvious to
me that the two methods are not conceptually the "same thing" for which
overloading is appropriate. They are different things, strongly indicated
by them having different accessibility.)
HTH,
--Eljay