class A {
public:
A() {auto tmp = &A::foo;}
protected:
void foo() {}
};
class B : public A {
public:
B() {auto tmp = &A::foo;}
};
Class A
compiles no problem. Class B
yields a compilation error:
'A::foo' : cannot access protected member declared in class 'A'
Why is that, what's the rationale? Is there a way to circumvent this (if I need that pointer for a callback, std::function
etc.)?