Use of pointer to protected member function won't compile in 3.4.4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux