Here is an example of what I want to accomplish and how:
class MyClass
{
public:
void Dummy() const{}
};
typedef void (MyClass::*MemFunc)();
void (const MyClass * instance)
{
MemFunc func=&MyClass::Dummy;
(const_cast<MyClass *>instance->*func)();
}
Why do compilers (gcc 3 and 4) insist that the instance be non-constant? Could there be a problem with const_cast?
FYI: instance` is not necessarily const, I just don't want the caller to call with it.
What's going on here?
Sasha
source
share