Namespaces qualified with :: in C++

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

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

5条回答
  •  梦谈多话
    2021-01-05 02:53

    This invokes something called the qualified name lookup:

    $3.4.3/1 - "The name of a class or namespace member can be referred to after the :: scope resolution operator (5.1) applied to a nested-name-specifier that nominates its class or namespace. During the lookup for a name preceding the :: scope resolution operator, object, function, and enumerator names are ignored. If the name found is not a class-name (clause 9) or namespace-name (7.3.1), the program is ill-formed."

提交回复
热议问题