当前位置:网站首页>Introduction to namespace Basics
Introduction to namespace Basics
2022-07-07 04:38:00 【Just stay at home】
In cooperative programming with others , Naming conflicts may occur . And the bigger the project , The more trouble the naming conflict causes .
So is there any way that we can use the same name without using conflict , Here is to introduce C++ In grammar namespace Namespace .
Catalog
One . Basic usage
namespace Namespaces can store variables , Structure , Function, etc. . When using, we need to define namespace To declare .
For example, we want to define two functions car, It also needs to be called in the same main function , Then you can define two namespace To store these two functions separately . Directly call... In the main function namespace that will do
call namespace We need to use the scope symbol (::). For example, in the following program , When we want to use BYD Of car when , Just call in the main function BYD::car() that will do . This is equivalent to telling the computer , When it sees :: The symbol , It needs to be in BYD This namespace Find car function . Don't look for other places , Not if you find it .
Functions can be defined directly in the namespace namespace Directly in , Of course , It can also be defined outside the domain like the following program . At this time , When defining functions , Call the namespace first , Let the computer know that I want to define something namespace The function in .
Two . Standard library
Using the standard library std When , We have three calling methods .
One , Is used every time a standard library function is called std::.
Two , Is to define the standard library for global use , That is to say in the header using namespace std; .
The first method is too cumbersome , The second definition is global and may cause conflict , Then we can use the third definition method .
3、 ... and , Define high-frequency objects as global use . namely using std:: object .
It's not easy to create , Let's support San Lian If there is a mistake , Please correct
边栏推荐
- VM virtual machine operating system not found and NTLDR is missing
- 赠票速抢|行业大咖纵论软件的质量与效能 QECon大会来啦
- 图灵诞辰110周年,智能机器预言成真了吗?
- MySQL forgot how to change the password
- SSM+JSP实现企业管理系统(OA管理系统源码+数据库+文档+PPT)
- Case reward: Intel brings many partners to promote the innovation and development of multi domain AI industry
- 视频融合云平台EasyCVR视频广场左侧栏列表样式优化
- Complimentary tickets quick grab | industry bigwigs talk about the quality and efficiency of software qecon conference is coming
- Gpt-3 is a peer review online when it has been submitted for its own research
- mpf2_线性规划_CAPM_sharpe_Arbitrage Pricin_Inversion Gauss Jordan_Statsmodel_Pulp_pLU_Cholesky_QR_Jacobi
猜你喜欢
案例大赏:英特尔携众多合作伙伴推动多领域AI产业创新发展
【实践出真理】import和require的引入方式真的和网上说的一样吗
DFS和BFS概念及实践+acwing 842 排列数字(dfs) +acwing 844. 走迷宫(bfs)
Formation continue en robotique (automatisation) - 2022 -
深耕开发者生态,加速AI产业创新发展 英特尔携众多合作伙伴共聚
What if the win11 screenshot key cannot be used? Solution to the failure of win11 screenshot key
[coded font series] opendyslexic font
Hardware development notes (10): basic process of hardware development, making a USB to RS232 module (9): create ch340g/max232 package library sop-16 and associate principle primitive devices
Lessons and thoughts of the first SQL injection
Oracle -- 视图与序列
随机推荐
Oracle -- 视图与序列
Comment les tests de logiciels sont - ils effectués sur le site Web? Testez la stratégie!
The request request is encapsulated in uni app, which is easy to understand
On the 110th anniversary of Turing's birth, has the prediction of intelligent machine come true?
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
NFT meta universe chain diversified ecosystem development case
Win11远程桌面连接怎么打开?Win11远程桌面连接的五种方法
Deeply cultivate the developer ecosystem, accelerate the innovation and development of AI industry, and Intel brings many partners together
Digital chemical plant management system based on Virtual Simulation Technology
Kotlin compose text supports two colors
计数排序基础思路
Camera calibration (I): robot hand eye calibration
Fiance donated 500million dollars to female PI, so that she didn't need to apply for projects, recruited 150 scientists, and did scientific research at ease!
树与图的深度优先遍历模版原理
Win11图片打不开怎么办?Win11无法打开图片的修复方法
[written to the person who first published the paper] common problems in writing comprehensive scientific and Technological Papers
EasyCVR无法使用WebRTC进行播放,该如何解决?
ESG全球领导者峰会|英特尔王锐:以科技之力应对全球气候挑战
namespace基础介绍
Implementation of JSTL custom function library