C + + namespaces

Source: Internet
Author: User

namespaces : Functions, classes, variables, etc. that distinguish the same names in different libraries as additional information, define the context, define the scope;

namespace name{...} Definition of namespaces

Name:: Code; Calls a function or variable with a namespace code

The using namespace directive tells the compiler that subsequent code uses the name in the specified namespace

disjoint namespaces :

A namespace consists of several individually defined parts that can be scattered across multiple files;

A part of the namespace is in a separate file, you need to declare the name;

You can define a new namespace, or you can add new elements of an existing namespace;

  

nested namespaces :

Another namespace can be defined in one namespace;

Namespace name1

{

Namespace Name2

{

}

}

To access members in a nested namespace by :: operator:

Using namespace name1:: name2; If you use a slow look at 1, the elements in namespace 2 are also available;

C + + 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.