次の C++ コードを考えてみましょう。
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;
}
コンパイル エラーが発生しました: In member function void B<Derived>::foo()
:
template_inherit.cpp:12: エラー: 'usable_' はこのスコープで宣言されていません。
何故ですか ?良い修正はありますか?