Ru-Brd |
5.2 Using this->For class templates with base classes, using a name x by itself is not always equivalent to this->x , even though a member x is inherited. For example: template <typename T> class Base { public: void exit(); }; template <typename T> class Derived : Base<T> { public: void foo() { exit(); // calls external exit() or error } }; In this example, for resolving the symbol exit inside foo() , exit() defined in Base is never considered . Therefore, either you have an error, or another exit() (such as the standard exit() ) is called. We discuss this issue in Section 9.4.2 on page 136 in detail. For the moment, as a rule of thumb, we recommend that you always qualify any symbol that is declared in a base that is somehow dependent on a template parameter with this-> or Base<T>:: . If you want to avoid all uncertainty, you may consider qualifying all member accesses (in templates). |
Ru-Brd |