开发者

namelookup with Unqualified name : C++0x draft n3290

开发者 https://www.devze.com 2023-03-12 22:51 出处:网络
A point from the ISO C++ Draft n3290 : 3.4.0 2nd point A name “looked up in the context of an expression” is looked up as an unqualified name in the 开发者_运维技巧scope where the expression is f

A point from the ISO C++ Draft n3290 : 3.4.0 2nd point

A name “looked up in the context of an expression” is looked up as an unqualified name in the 开发者_运维技巧scope where the expression is found.

Would someone please explain this statement with an example?


It says that the scope which contains the expression will be searched for the name. i.e.

namespace foo { 
  struct bar {
    void foobar() {
      do_something();
    }
  };
}

if you have this code the name do_something will be searched in the scope of foobar, bar, foo and in the global scope (and not in other namespaces, structs or function scopes)

0

精彩评论

暂无评论...
验证码 换一张
取 消