From: Paul Dubuc <pdubuc@cas.org>
To: gcc-help@gcc.gnu.org
Subject: Use of pointer to protected member function won't compile in 3.4.4
Date: Tue, 12 Jul 2005 21:47:00 -0000 [thread overview]
Message-ID: <42D43A2E.4060700@cas.org> (raw)
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
next reply other threads:[~2005-07-12 21:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-12 21:47 Paul Dubuc [this message]
2005-07-12 21:51 ` corey taylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42D43A2E.4060700@cas.org \
--to=pdubuc@cas.org \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).