Namespaces qualified with :: in C++

前端 未结 5 1933
余生分开走
余生分开走 2021-01-05 02:46

What does it mean if namespace in C++ is qualified with ::? For example ::testing::Test.

5条回答
  •  臣服心动
    2021-01-05 03:05

    If :: is used on the left side it means the global scope.

    If you want an analogy with the filesystem, testing::Test would be a kind of relative path (with respect of König lookup) whereas ::testing::Test would be an absolute path. I hope this analogy makes it clearer and doesn't mess up your mind :-).

提交回复
热议问题