什么是“::”意味着“:: tolower”? [英] What does the "::" mean in "::tolower"?

查看:173
本文介绍了什么是“::”意味着“:: tolower”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到过这样的代码:

std::string str = "wHatEver";
std::transform(str.begin(), str.end(), str.begin(), ::tolower);

我有一个问题:什么意思 :: 之前的tolower?

And I have a question: what does mean :: before tolower?

std :: tolower :: tolower 工作正常

推荐答案

意味着它明确使用 tolower 在全局命名空间(可能是stdc lib)。

Means that it is explicitly using the tolower in the global namespace (which is presumably the stdc lib one).

示例:

void foo() {
    // This is your global foo
}

namespace bar {
    void foo() {
        // This is bar's foo
    }
}

using namespace bar;

void test() {
    foo();   // Ambiguous - which one is it?
    ::foo(); // This is the global foo()
}

这篇关于什么是“::”意味着“:: tolower”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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