:: without a namespace

前端 未结 3 2017
暖寄归人
暖寄归人 2020-12-01 16:41

Consider the following line of code:

::CGContextRef cgContext = cocoa::createCgBitmapContext( surface );

How come there\'s no names

相关标签:
3条回答
  • 2020-12-01 17:14

    The :: refers to the global namespace.

    0 讨论(0)
  • 2020-12-01 17:29

    :: without any namespace name before it means it refers Global Namespace.

    ::CGContextRef cgContext = cocoa::createCgBitmapContext( surface );
    

    means refer to CGContextRef in the Global Namespace.

    0 讨论(0)
  • 2020-12-01 17:31

    :: in ::CGContextRef means global namespace, which means CGContextRef is defined in the global namespace.

    int x = 10; 
    namespace test
    {
        int x = 100;
        void f() 
        {
             std::cout << x << std::endl;  //prints 100
             std::cout << ::x << std::endl; //prints 10
        }     
    }
    

    See complete demo here : http://www.ideone.com/LM8uo

    0 讨论(0)
提交回复
热议问题