先把各家的解释复制在这里,意思都差不多。
You can tell the compiler to use the global identifier rather than the local identifier by prefixing the identifier with ::, the scope resolution operator.
Remarks
The identifier can be a variable or a function.
If you have nested local scopes, the scope resolution operator does not provide access to identifiers in the next outermost scope. It provides access to only the global identifiers.
Example
This example has two variables named amount. The first is global and contains the value 123. The second is local to the main function. The scope resol
C++双冒号作用域解析符详解

本文介绍了C++中的双冒号作用域解析符,用于区分全局标识符和局部标识符,以及如何在类和命名空间中使用它来访问特定变量或函数。示例展示了如何使用作用域解析符避免局部变量与全局变量名称冲突。
最低0.47元/天 解锁文章
1919





