This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Use of pointer to protected member function won't compile in 3.4.4
- From: corey taylor <corey dot taylor at gmail dot com>
- To: Paul Dubuc <pdubuc at cas dot org>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 12 Jul 2005 16:51:40 -0500
- Subject: Re: Use of pointer to protected member function won't compile in 3.4.4
- References: <42D43A2E.4060700@cas.org>
- Reply-to: corey taylor <corey dot taylor at gmail dot com>
This has been changed since 3.4.0 and is noted in the last bullet of
the C++ changes:
http://gcc.gnu.org/gcc-3.4/changes.html
corey
On 7/12/05, Paul Dubuc <pdubuc@cas.org> wrote:
> This code will compile with g++ 3.3.4, but 3.4.4 gives me the following error:
>
> Test.cc: In member function `const char* Derived::getCharge() const':
> Test.cc:18: error: `char* Base::makeCharge_(const char*) const' is protected
> Test.cc:31: error: within this context
>
> Why can't the Derived class use a pointer to it's Base class' protected member
> function? Is this a bug in 3.4.4, or is this no longer allowed?
>
> Help!
>
> Here's the code:
>
> class Base {
>
> protected:
>
> const char * getAttr_(unsigned char type,
> char * (Base::*pf)(const char *) const) const;
>
> char * makeCharge_(const char *) const;
> };
>
> const char * Base::getAttr_(unsigned char type,
> char * (Base::*pf)(const char *) const) const
> {
> return 0;
> }
>
> char * Base::makeCharge_(const char * ptr) const
> {
> return 0;
> }
>
> class Derived : public Base {
>
> public:
>
> const char * getCharge() const;
> };
>
> const char * Derived::getCharge() const
> {
> return(getAttr_(0, &Base::makeCharge_));
> }
>
>
> --
> Paul M. Dubuc
>
> "It is not enough to do your best; you must know what to do, and THEN do your
> best." -- W. Edwards Deming
>