Saturday, January 18, 2014

this pointer template c++

this pointer template c++ : templates tutorial ccplusplus.com

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:


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. 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).








-----------------------------------------------------------------
See Also:
-----------------------------------------------------------------

-----------------------------------------------------------------

No comments:

Post a Comment