Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: Intermediate
Oct 29, 1998



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Koenig Lookup

Andrew Koenig devised an algorithm for resolving namespace members' lookup. This algorithm is used in all standard-conforming compilers to handle cases like the following:
namespace MINE {
  class C {};
  void func(C);  

MINE::C c; // global object of type MINE::C

void main() {
  func( c ); // OK, MINE::f called 
No using declaration or using directive exists in the program. Still, the compiler did the right thing by applying Koenig lookup. Koenig lookup instructs the compiler to look not just in the usual places such as the local scope, but also the namespace that contains the argument's type.
Danny Kalev
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date