I have a Base class and derived another class from it. The derived class has a function which takes as an argument const Base&
and calls its protected member function. I get an error saying that the function being called is protected in that context. I'd like to know why that happens and can I solve it without making the protected function in base class public
.
class Base {
protected:
void call() const {}
};
class C : public Base {
public:
void func(const Base& b) {
b.call();
}
};
I tried adding using Base::call
in the derived class but that didn't help