May 2012

Core C++, 1 of N: Name Lookup—Stephan T. Lavavej

Core C++, 1 of N: Name Lookup -- Stephan T. Lavavej

Stephan T. Lavavej, aka STL, will take us on a journey of discovery within the exciting world of Core C++. We know lots of folks are either coming back to C++, coming to C++, or have never left C++. This lecture series, in n parts, is for all of you! Only STL can make that work (novice, intermediate, and advanced all bundled together and presented in a way only STL can do).

In the following code, which functions are called? Why? Analyze the implications?


namespace A {
      struct X;
      struct Y;
      void f( int );
      void g( X );

namespace B {
       void f( int i ) {
            f( i );   // which f()?
        void g( A::X x ) {
             g( x );   // which g()?
        void h( A::Y y ) {
             h( y );   // which h()?

We recommend you watch this entire episode before playing around with Herb's sample above (and don't read the GotW answer, either! That's cheating. Learn from STL. He's an outstanding teacher, as you know).

Tune in. Enjoy. Learn.