Given the following c++ classes:
// base class
class A {
protected:
void writeLogEntry(const std::string& message);
};
// derived class
class B : public A { };
// c.h
class C {
myMethod();
}
// c.cpp - uses B
C::myMethod()
{
B b;
b.writeLogEntry("howdy");
}
As expected, class C fails to compile with the error "cannot access protected member declared in class 'A'.
Should I a) make the method A::writeLogEntry public, or b) make a public method B::writeLogEntry(message) that passes the message param to A::writeLogEntry(message), or c) something else entirely?
Thanks
P