In a templated derived class, why do I need to qualify base class member names with “this->” inside a member function?

C++ answer (general answer) Consider a template class Derived with a template base class: template <typename T> class Base { public: int d; }; template <typename T> class Derived : public Base<T> { void f () { this->d = 0; } }; this has type Derived<T>, a type which depends on T. So this has … Read more

What is “Argument-Dependent Lookup” (aka ADL, or “Koenig Lookup”)?

Koenig Lookup, or Argument Dependent Lookup, describes how unqualified names are looked up by the compiler in C++. The C++11 standard ยง 3.4.2/1 states: When the postfix-expression in a function call (5.2.2) is an unqualified-id, other namespaces not considered during the usual unqualified lookup (3.4.1) may be searched, and in those namespaces, namespace-scope friend function … Read more