X hits on this document

938 views

0 shares

0 downloads

0 comments

82 / 396

Chapter ‎18   Unsafe code

Otherwise, if the namespaces imported by the using-namespace-directives of the namespace declaration contain exactly one type with the given name, then the namespace-or-type-name refers to that type.

Otherwise, if the namespaces imported by the using-namespace-directives of the namespace declaration contain more than one type with the given name, then the namespace-or-type-name is ambiguous and an error occurs.

Otherwise, the namespace-or-type-name is undefined and a compile-time error occurs.

Otherwise, the namespace-or-type-name is of the form N.I, where N is a namespace-or-type-name consisting of all identifiers but the rightmost one, and I is the rightmost identifier. N is first resolved as a namespace-or-type-name. If the resolution of N is not successful, a compile-time error occurs. Otherwise, N.I is resolved as follows:

If N is a namespace and I is the name of an accessible member of that namespace, then N.I refers to that member and, depending on the member, is classified as a namespace or a type.

If N is a class or struct type and I is the name of an accessible type in N, then N.I refers to that type.

Otherwise, N.I is an invalid namespace-or-type-name, and a compile-time error occurs.

3.8.1 Fully qualified names

Every namespace and type has a fully qualified name, which uniquely identifies the namespace or type amongst all others. The fully qualified name of a namespace or type N is determined as follows:

If N is a member of the global namespace, its fully qualified name is N.

Otherwise, its fully qualified name is S.N, where S is the fully qualified name of the namespace or type in which N is declared.

In other words, the fully qualified name of N is the complete hierarchical path of identifiers that lead to N, starting from the global namespace. Because every member of a namespace or type must have a unique name, it follows that the fully qualified name of a namespace or type is always unique.

The example below shows several namespace and type declarations along with their associated fully qualified names.

class A {}// A

namespace X// X { class B// X.B { class C {}// X.B.C }

namespace Y// X.Y { class D {}// X.Y.D } }

namespace X.Y// X.Y { class E {}// X.Y.E }

3.9 Automatic memory management

Copyright Microsoft Corporation 1999-2003. All Rights Reserved.69

Document info
Document views938
Page views938
Page last viewedWed Dec 07 22:51:00 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments