为什么我必须通过this指针访问模板基类成员?
如果下面的类不是模板,我可以x在derived课堂上使用。但是,使用下面的代码,我必须使用this->x。为什么?
template <typename T>class base {protected:
int x;};template <typename T>class derived : public base<T> {public:
int f() { return this->x; }};int main() {
derived<int> d;
d.f();
return 0;}慕斯王
慕虎7371278