gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-27 23:48:50 26 4
gpt4 key购买 nike

    #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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com