This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
problems taking a pointer to member-function of a protected method in a derived class
- From: Rene Buergel <rbuergel at HTWM dot De>
- To: gcc-help at gcc dot gnu dot org
- Date: Sun, 21 Oct 2007 18:39:28 +0200
- Subject: problems taking a pointer to member-function of a protected method in a derived class
I don't know, if this list is appropriate, as this is a general
C++-Question, but anyway...
I ran into some problems with the following Codepiece:
class Base
{
protected:
typedef void (Base::*FuncPtr)();
virtual void func();
};
class Derived: public Base
{
virtual void func();
Derived()
{
FuncPtr p = &Base::func;
}
};
g++ tells me, that i can't access it, because it is taken via Base. If
the method wouldn't be virtual, it could be referenced as "&Derived::func".
Currently the only solution to me seems to make func public - which is
not intended by design.
Are there other possibilities?