当前位置:网站首页>常量指针和指针常量
常量指针和指针常量
2022-07-02 06:27:00 【programmercherry】
常量指针和指针常量的区别详解
* (指针)和 const (常量)谁在前就先读谁;
* 象征指针,const 象征内容;
谁在前面谁就不允许改变
1. 常量指针
int a = 10;
int b = 20;
const int* p = &a; //const在前,定义为常量指针
p = &b; //正确,指针的指向可以更改
//*p = 20; //错误,指针指向的值不可以改
特点:指针的指向(指向的地址)可以修改,但指针指向的值不可以修改
(内容不可以重新赋值,内容的改变可以通过修改地址指向后变换)
常量指针本质是指针,常量修饰它,表示这个指针是一个指向常量的指针(变量)。指针指向的对象是常量,那么这个对象不能被更改。
2.指针常量
int a = 10;
int b = 20;
int* const p = &a; //*在前,定义为指针常量
*p = 20; //正确,指针指向的值可以更改
//p = &b; //错误,指针的指向不可以改
特点:指针的指向(指向的地址)不可以修改,指针指向的值可以修改。
必须初始化,地址跟随一生。
指针常量的本质是一个常量,并且使用指针来修饰它,那么说明这个常量的值应该是一个指针
扩展:
this 指针的本质是 指针常量 指针的指向不可以修改
边栏推荐
- Mmdetection trains its own data set -- export coco format of cvat annotation file and related operations
- open3d学习笔记二【文件读写】
- Daily practice (19): print binary tree from top to bottom
- Meta Learning 简述
- Gensim如何冻结某些词向量进行增量训练
- 【Random Erasing】《Random Erasing Data Augmentation》
- In the era of short video, how to ensure that works are more popular?
- 浅谈深度学习模型中的后门
- 简易打包工具的安装与使用
- [C # note] the data in DataGridView saved in WinForm is excel and CSV
猜你喜欢

Feature Engineering: summary of common feature transformation methods

【BiSeNet】《BiSeNet:Bilateral Segmentation Network for Real-time Semantic Segmentation》
![Open3d learning note 3 [sampling and voxelization]](/img/71/0b2ac5dfd538017de639e5651c7f46.png)
Open3d learning note 3 [sampling and voxelization]
![Open3d learning note 5 [rgbd fusion]](/img/0a/41d38e4b0295b6674143f3f74a4a8d.png)
Open3d learning note 5 [rgbd fusion]

【MagNet】《Progressive Semantic Segmentation》

What if the laptop can't search the wireless network signal

图像增强的几个方法以及Matlab代码

open3d学习笔记五【RGBD融合】

用MLP代替掉Self-Attention

【FastDepth】《FastDepth:Fast Monocular Depth Estimation on Embedded Systems》
随机推荐
【BiSeNet】《BiSeNet:Bilateral Segmentation Network for Real-time Semantic Segmentation》
ABM thesis translation
It's great to save 10000 pictures of girls
用MLP代替掉Self-Attention
包图画法注意规范
CPU register
Organigramme des activités
我的vim配置文件
【DIoU】《Distance-IoU Loss:Faster and Better Learning for Bounding Box Regression》
【Programming】
【Hide-and-Seek】《Hide-and-Seek: A Data Augmentation Technique for Weakly-Supervised Localization xxx》
服务器的内网可以访问,外网却不能访问的问题
[mixup] mixup: Beyond Imperial Risk Minimization
How to turn on night mode on laptop
【C#笔记】winform中保存DataGridView中的数据为Excel和CSV
Mmdetection trains its own data set -- export coco format of cvat annotation file and related operations
【Paper Reading】
Memory model of program
Meta Learning 简述
open3d学习笔记四【表面重建】