这是C ++中的不合格查询吗? [英] Is this unqualified lookup in c++?

查看:98
本文介绍了这是C ++中的不合格查询吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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


        std::cout << k;


        return 0;
    }

我正在努力理解合格查询和不合格查询之间的区别,以及它们如何使用命名空间进行处理;词组

I am struggling to understand the difference between qualified and unqualified lookup, and how they deal with using namespace ; phrases

现在,我想说明一下?这是k导致合格的查找吗?

For now, I would like to make clear ?Here k causes qualified lookup right?

推荐答案

它是不合格名称查询:

对于不合格的名称,该名称不会出现在 在范围解析运算符::: 的右侧,名称查找将检查 范围,如下所述,直到找到至少一个声明 任何类型,此时查找停止,并且没有其他作用域 检查过.

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不在范围解析运算符的右侧.

as k does not appear to the right of a scope resolution operator.

这篇关于这是C ++中的不合格查询吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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