php--namespaces

Source: Internet
Author: User

First, Why use namespaces

A large project is often done independently by a number of people, different people complete different parts, and finally combined into a complete program. Since each header file is designed by different people, it is possible to name the defined class or function in different headers with the same name, so that there is a naming conflict in the program. Not only that, it is possible that our own defined names will conflict with names in the C + + library.

The name conflict is that there are two or more entities with the same name in the same scope, in order to resolve the naming conflict, the namespace is introduced in C + +, the so-called namespace is a scope that can be defined by the user, in different scopes can define the same name of the variable, non-interference, The system can differentiate them.

Second, What is a namespace

A namespace is a memory area named by the program designer, which is separated from other global entities by specifying a number of named spatial domains and storing some global entities in each namespace, respectively.

In layman's terms, each namespace is a namespace domain, and global entities stored in the namespace domain are valid only within the domain. namespaces restrict the domain of global entities to resolve naming conflicts reasonably.

php--namespaces

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.