考虑以下代码行:
::CGContextRef cgContext = cocoa::createCgBitmapContext( surface );
Run Code Online (Sandbox Code Playgroud)
为什么在::之前没有指定名称空间?这是否意味着它使用与您所在类相同的命名空间?
::in ::CGContextRef表示全局名称空间,表示CGContextRef在全局名称空间中定义.
int x = 10;
namespace test
{
int x = 100;
void f()
{
std::cout << x << std::endl; //prints 100
std::cout << ::x << std::endl; //prints 10
}
}
Run Code Online (Sandbox Code Playgroud)
请在此处查看完整演示:http://www.ideone.com/LM8uo
::在它之前没有任何命名空间名称意味着它指的是Global Namespace。
::CGContextRef cgContext = cocoa::createCgBitmapContext( surface );
Run Code Online (Sandbox Code Playgroud)
表示CGContextRef在全局命名空间中引用。
| 归档时间: |
|
| 查看次数: |
1860 次 |
| 最近记录: |