public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Use of pointer to protected member function won't compile in 3.4.4
@ 2005-07-12 21:47 Paul Dubuc
  2005-07-12 21:51 ` corey taylor
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Dubuc @ 2005-07-12 21:47 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Use of pointer to protected member function won't compile in 3.4.4
  2005-07-12 21:47 Use of pointer to protected member function won't compile in 3.4.4 Paul Dubuc
@ 2005-07-12 21:51 ` corey taylor
  0 siblings, 0 replies; 2+ messages in thread
From: corey taylor @ 2005-07-12 21:51 UTC (permalink / raw)
  To: Paul Dubuc; +Cc: gcc-help

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
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-07-12 21:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-12 21:47 Use of pointer to protected member function won't compile in 3.4.4 Paul Dubuc
2005-07-12 21:51 ` corey taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).