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]

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?



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