Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
このような状況で、この場合x、修飾されていない基底クラスのメンバーにアクセスできないのはなぜB1ですか? 私にはあいまいに見えません…</p>
x
B1
template<class T> struct A { T x; }; template<class T> struct B1 : A<T> { T f() { return A<T>::x; } }; struct B2 : A<int> { int f() { return x; } };
は依存していないためx、テンプレートが定義されているコンテキストで検索されます。そのコンテキストでは、コンパイラは について何も知らずT、依存する基本クラスを調べることができません。たとえば、何が何であるかを知らずに、どのようにして何かをA<T>知ることTができますか。A(メンバーが全く違うなどの特殊化もありえます。)
T
A<T>
A