Namespace and Import

Source: Internet
Author: User

Definition: Namespaces are the name of a group of named objects that are organized, categorized, and identified, and are an important basis for modular programming.


Role:

The name of the object defined inside the namespace is managed by the namespace. When referencing the name of an external namespace, you need to add a namespace prefix before the object name. Different namespaces can have the same name without interfering with each other, effectively avoiding the name pollution. A namespace can contain another namespace, using the member operator "." Between names. A connection, known as a namespace path. The primary purpose is to organize and reuse code.

namespace, as the name implies, is called the name of a directory, different names, may have the same function, such as the console under the Open function, IO also has the open function. Can be seen as a different directory. Therefore, the name space is called Web.layout.debug, the corresponding directory is web\layout\debug\. This means that, using a function, first import his root directory, his root directory is the code of the namespace, and then through the. To find the corresponding directory successively, use this function. function is the pre-written function of the package, the role of the object with a formal code first occupy a bit, the code name is called formal parameters, the use of the time through (), in parentheses to the actual package of the function to operate the object can be used to pass in. The actual contents of this parenthesis are then given to the function, instead of the position of the formal parameter to run.


Define namespace Syntax:

Namespace NAME {

Member, name internal space code

}


Namespaces can be nested within the namespace, accessed in the name space. Internal namespace. Member ", the embedded namespace function, to access the top-level namespaces to use: Operator. “..” As a prefix, the namespace is the global name.


============================================================

Special namespaces: Global and Self:

1. Global

The global namespace is the default, and when the AAU code file is loaded, it is run in the global namespace by default.

2. Self

Self represents the current namespace.


The default namespace for a variable is the global namespace, and you can use namespace to change the namespace of the specified code block. You can use the Self keyword to access the current namespace. Use.. operator to access the global namespace.



=============================================================

Import the library file by importing the method.


Standard libraries and kernel libraries:


650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/80/09/wKioL1c1coSDH04gAAiHHT7MIa4713.png "title=" Untitled. png "alt=" Wkiol1c1cosdh04gaaihht7mia4713.png "/>





This article from the "One Night Off" blog, declined to reprint!

Namespace and Import

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.