Consider the following C++ code,
template <typename Derived>
struct A
{
bool usable_;
};
template <typename Derived>
struct B : A< B<Derived> >
{
void foo()
{
usable_ = false;
}
};
struct C : B<C>
{
void foo()
{
usable_ = true;
}
};
int main()
{
C c;
}
I got compilation error: In member function void B<Derived>::foo()
:
template_inherit.cpp:12: error: 'usable_' was not declared in this scope.
Why is that ? Any good fix ?