c++ - 这是 C++ 中的不合格查找吗?

标签 c++ lookup

    #include <iostream>
    namespace X
    {
        int k  = 8;
    }
    int main()
    {
        using namespace X;
        int  k = 0;


        std::cout << k;


        return 0;
    }

我正在努力理解合格查找和非合格查找之间的区别,以及它们如何处理使用命名空间;短语

现在,我想澄清一下?这里的 k 会导致合格查找吗?

最佳答案

unqualified name lookup :

For an unqualified name, that is a name that does not appear to the right of a scope resolution operator ::, name lookup examines the scopes as described below, until it finds at least one declaration of any kind, at which time the lookup stops and no further scopes are examined.

as k 没有出现在范围解析运算符的右侧。

关于c++ - 这是 C++ 中的不合格查找吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48359294/

相关文章:

python - 有没有办法在 O(1) 时间内从集合中获取项目?

c++ - GLEW 和 VS 2012 : unresolved external symbols

c++ - 在 Visual Studio 2015 中的 C++ STL 中出现错误

c++ - 在 C++ 中打开和解析文件以检查标点符号并使用两个函数转换为小写

database - 如何仅查找mongo中的特定字段

r - 如何将值从一个数据帧传输到另一个数据帧?

c++ - 类解决方法的虚拟模板成员

c++ - 不允许类型名称

typescript - 如何让 TypeScript 查找类型在这种情况下工作?

excel - 解释LOOKUP公式