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: 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



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