Summary:
1.: Root namespace or anonymous space of the ant table
2. when I is used in: ant: I and: ant: blas: I, ant: detail: I, default call ant: detail: I
3. for calling the level-level namespace, add the corresponding namespace
4. Saved domain namespaces
5. Even if there are multiple namespaces with the same name, no error will be reported. It is called according to the most partial call principle. If the global variable is the same as the local variable name, local variables are preferentially called.
Code:
<SPAN style = "FONT-SIZE: 14px"> # include <stdlib. h ># include <iostream> namespace detail {const int I = 99;} namespace ant {namespace blas {const int I = 0;} // end blasconst int I = 3; namespace detail {const int I = 33; void test () {std: cout <"I:" <I <std: endl; // 33 std :: cout <": detail: I" <: detail: I <std: endl; // 99 std: cout <"detail :: I "<detail: I <std: endl; // 33 std: cout <": ant: blas: I: "<:: ant: blas: I <std: endl; // 0 std: cout <"ant: blas: I" <: ant :: blas: I <std: endl; // 0 std: cout <"blas: I" <blas: I <std: endl; // 0 level/std: cout <": blas: I" <: blas: I <std: endl; // error std:: cout <"ant: I" <ant: I <std: endl; // 3 }}// end detail} // end namespace antusing namespace std; int main () {ant: detail: test (); return 0 ;} </SPAN>