A small example to reproduce the error in Visual Studio (Community) 2022:
#include <iostream>
#include <memory>
class Base {
public:
virtual void b();
protected:
std::string Method() {
return "Base::Method";
}
};
class SubA : public Base {
public:
// Prevent compiler from optimizing class away.
int doSomething() {
return 7;
}
};
int main() {
SubA sa;
sa.doSomething();
sa.Method(); // <-- Function is inaccessible.
}
Why is the error? The inheritance is public and I'm calling Method on an object from the SubA class.