参考材料:C++ primer 5th edition 7.4.1节
首先,明确name lookup是个什么工作。
name lookup, "the process of findging which declarations match the use of a name"。
这个工作是compiler做的事情
然后,我暂时对compiler做name lookup 的规则理解:
总的规则是,使用一个name,这个name必须在这个使用点之前已经declare过。因此,name lookup 在使用点之前进行查找。
有一个特殊点,就是在class member function body中使用的一个name, 只要这个name在class中有declaration(不管是在这个member function body之前还是之后),就都可以使用。但是如果在class中没有declaration,在class 外寻找时,就只能找出现在class之前的declaration。