If the classes below were not templates I could simply have x
in the derived
class. However, with the code below, I have to use this->x
. Why?
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;}