c++ - Qualified access needed when inheriting from template -
this question has answer here:
in situation this, why can't access base class member x
unqualified in b1
case? doesn't loook ambiguous me…
template<class t> struct { t x; }; template<class t> struct b1 : a<t> { t f() { return a<t>::x; } }; struct b2 : a<int> { int f() { return x; } };
because x
not dependent, looked in context template defined. in context, compiler knows nothing of t
, , cannot in dependent base classes. how can it, example, know of a<t>
without knowing t
is. (there specialization of a
example, different members.)
Comments
Post a Comment