namelookup与非限定名称:C ++ 0x draft n3290 [英] namelookup with Unqualified name : C++0x draft n3290

查看:159
本文介绍了namelookup与非限定名称:C ++ 0x draft n3290的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自ISO C ++ Draft n3290的点:3.4.0第二点

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();
    }
  };
}



如果您有此代码名称 do_something <将在 foobar bar foo 和全局作用域(而不是其他命名空间,结构或函数作用域)

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)

这篇关于namelookup与非限定名称:C ++ 0x draft n3290的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆