Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Cpp Namespace

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

1. All identifiers in namespace censor + are defined in a namespace called std, and namespaces are the various visible ranges of identifiers that control their scope.

2.std is the standard namespace of C++. Identifiers in the C++ standard library are defined in std, such as iostream,vector.

3.using namespace std; means to use the identifiers in the C++ standard library.

4. In order to solve the conflict of large program identifiers

5. Use the entire namespace: using namespace name

Use the variable in the namespace: using name::variable

Variable that uses the default namespace: variable

All identifiers in the default namespace can be used directly by default

6. An error will be reported if you directly use the identifier of the namespace instead of the namespace, as shown in the following figure

7. In the following two cases, @ refers to the variable @ 2 through the namespace plus a double colon to indicate the use of the namespace.

8. For the definition and use of namespaces, see the following code

1 # include 23 namespace Spaceone 4 {5 int a = 10; 6} 7 8 namespace Spacetwo 9 {10 int a = 50 X 11 namespace Spacethree12 {13 struct date14 {15 int year;16 int month;17 int day;18}; 19} 20} 21 22 23 24 void main () 25 {26 using namespace Spaceone;27 28 using Spacetwo::Spacethree::date 29 30 std::cout

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report