Why can't i use partly qualified namespaces during object initialization?

前端 未结 4 1798
不知归路
不知归路 2020-12-28 20:59

I suspect this is a question which has been asked many times before but i haven\'t found one.

I normally use fully qualified namespaces if i don\'t use that type of

4条回答
  •  不知归路
    2020-12-28 21:08

    This is documented in the standard in 3.8 Namespace and Type Names, but it's a bit convoluted to follow.

    The gist of it that a partial namespace reference is only looked for in the namespace where it occurs, and each layer outwards. using-directives are not checked.

    In your example, ns_1_1.Foo would be found if Foo is found anywhere in:

    Program.Program.ns_1_1.Foo
    Program.ns_1_1.Foo
    ns_1_1.Foo
    

提交回复
热议问题