可能重复:
What's the purpose of a leading “::” in a C++ method call
This gtest有示例代码。
::testing::AssertionResult IsEven(int n) {
if ((n % 2) == 0)
return ::testing::AssertionSuccess();
else
return ::testing::AssertionFailure() << n << " is odd";
}
它是如何工作的?如果命名空间正在测试,是不是测试:: AssertionResult是正确的用法?
答案 0 :(得分:3)
::前缀是指全局命名空间,因此这就像绝对路径规范相对路径规范。