I am porting some legacy code from MS visual studio to Clang and run into a problem with protected data members. In short, my issue is this:
template<typename T>
class Base : public SuperBase<T> {
public:
Base(std::shared_ptr<Widget<T>> const& sb) : sb_(sb) {}
protected:
std::shared_ptr<Widget<T>> sb_;
}
template <typename T>
class Derived : public Base<T>
{
public:
Derived(std::shared_ptr<Widget<T>> const& sb) : Base<T>(sb) {}
double method(void) const { return sb_->number(); }
}
This compiles fine under MSVC++, but not under Clang. Clang complains:
use of undeclared indentifier sb_.
Following Meyers Effective C++ I don't use protected a lot and can rewrite the code not to use, but I am still wondering why Clang complains here as the Derived class should be able to see the protected members of the Base class. What am I missing?