Using the name space

Source: Internet
Author: User

16.2.1-Word Space Declaration

The Declaration of the namespace is the keyword "namespace" followed by the name Space name and the namespace body, and then a semicolon can be followed. The format is as follows:

namespace Qualified-identifier namespace-body;

The Declaration of a namespace appears either in the first line of the compilation unit (the source file) or as a member in the Declaration of another namespace. The first-declared namespace is a member of the global namespace, and a namespace declared within another namespace as a member of the outer namespace. In either case, the name space does not allow duplicate names.

The namespace implicitly uses the public modifier, and any access modifiers are not allowed at the time of declaration.

The following form can implement nested declarations of namespaces using a nested syntax:

Namespace N1. N2
{
 class a{}
 class b{}
}
the above code is equivalent to:

namespace N1
{namespace N2 {
   class A {}
   Class b{}}}

 
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.