当前位置:网站首页>2. Const pointer
2. Const pointer
2022-07-02 14:30:00 【Little BigUs】
const Qualifiers are used to mark a variable as read-only , But it's a little complicated when decorating pointers .
First ,const int *pa and int const *pa The effect is the same , These two are completely equivalent , This const Modification is *pa This whole , in other words *pa This whole is read-only , however pa( No addition *) It can be modified . The variable it points to can also be modified . for instance
int a = 100;
const int *pa = &a;
printf("%d\n",*pa);//100
a = 200;
printf("%d\n",*pa);//200
int a = 100;
int b = 200;
const int *pa = &a;
printf("%d\n",*pa);//100
pa = &b;
printf("%d\n",*pa);//200
int a = 100;
const int *pa = &a;
printf("%d\n",*pa);//100
*pa = 200;// Report errors ,*pa yes const Type , read-only
and int * const pa in pa It's also a pointer , But this const Modification is pa Instead of *pa This whole , in other words , At this time, you can use the *pa To modify the a The value of the , however pa It's immutable , That is to say pa Can only point to a 了 , You can't point him at b, because pa The value of is the address of the target it points to , This is read-only .
Of course we can use const int * const pa This format , In this way, it is pa and *pa All read-only .
边栏推荐
- 线性dp求解 最长子序列 —— 小题三则
- Basic knowledge of QT original code
- 《可供方案开发》口算训练机/数学宝/儿童口算宝/智能数学宝 LCD液晶显示驱动IC-VK1622(LQFP64封装),原厂技术支持
- Use of freemaker
- 跨服务器数据访问的创建链接服务器方法
- QT new project
- 途家木鸟美团夏日折扣对垒,门槛低就一定香吗?
- 给Android程序员的一些面试建议「建议收藏」
- Slashgear shares 2021 life changing technology products, which are somewhat unexpected
- [Hongke technology sharing] how to test DNS server: DNS performance and response time test
猜你喜欢

Use of swagger

【虹科技术分享】如何测试 DNS 服务器:DNS 性能和响应时间测试

In 2021, the global styrene butadiene styrene (SBS) revenue was about $3722.7 million, and it is expected to reach $5679.6 million in 2028

<口算練習機 方案開發原理圖>口算練習機/口算寶/兒童數學寶/兒童計算器 LCD液晶顯示驅動IC-VK1621B,提供技術支持

MySQL 45 lecture - learning the actual battle of MySQL in Geek time 45 Lecture Notes - 05 | easy to understand index (Part 2)

Certik released the defi security report in 2021, disclosing key data of industry development (PDF download link attached)

Uniapp automated test learning

Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022

The global special paper revenue in 2021 was about $27 million, and it is expected to reach $35 million in 2028. From 2022 to 2028, the CAGR was 3.8%

MySQL45讲——学习极客时间MySQL实战45讲笔记—— 04 | 深入浅出索引(上)
随机推荐
Custom events, global event bus, message subscription and publishing, $nexttick
P1042 [NOIP2003 普及组] 乒乓球
PyQt5_QScrollArea内容保存成图片
Yyds dry goods inventory software encryption lock function
Fabric.js 动态设置字号大小
《可供方案开发》口算训练机/数学宝/儿童口算宝/智能数学宝 LCD液晶显示驱动IC-VK1622(LQFP64封装),原厂技术支持
Advanced usage of C language -- function pointer: callback function; Conversion table
OpenHarmony笔记-----------(四)
< schéma de développement de la machine d'exercice oral > machine d'exercice oral / trésor d'exercice oral / trésor de mathématiques pour enfants / lecteur LCD de calculatrice pour enfants IC - vk1621
Qt新建项目
Adhere to the foundation of 20 minutes go every day II
Fabric.js 自由绘制椭圆
Certik released the defi security report in 2021, disclosing key data of industry development (PDF download link attached)
Convolutional neural network (Introduction)
There is no solution to the decryption error of the remote user 'sa' and the service master password mapped from the remote server 'to the local user' (null) /sa '
Quick analysis: easy to share the Internet
[to be continued] [UE4 notes] l5ue4 model import
MQ tutorial | exchange (switch)
Generally speaking, if the error of inconsistent tab and space occurs frequently
一般来讲,如果频繁出现inconsistent tab and space的报错