当前位置:网站首页>常量指针和指针常量
常量指针和指针常量
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 指针的本质是 指针常量 指针的指向不可以修改
边栏推荐
- 【BiSeNet】《BiSeNet:Bilateral Segmentation Network for Real-time Semantic Segmentation》
- Open3d learning note 5 [rgbd fusion]
- Yolov3 trains its own data set (mmdetection)
- What if a new window always pops up when opening a folder on a laptop
- open3d学习笔记五【RGBD融合】
- Thesis tips
- EKLAVYA -- 利用神经网络推断二进制文件中函数的参数
- label propagation 标签传播
- Common CNN network innovations
- 解决jetson nano安装onnx错误(ERROR: Failed building wheel for onnx)总结
猜你喜欢
【学习笔记】Matlab自编图像卷积函数
How to clean up logs on notebook computers to improve the response speed of web pages
【Hide-and-Seek】《Hide-and-Seek: A Data Augmentation Technique for Weakly-Supervised Localization xxx》
【AutoAugment】《AutoAugment:Learning Augmentation Policies from Data》
The difference and understanding between generative model and discriminant model
Hystrix dashboard cannot find hystrix Stream solution
【Wing Loss】《Wing Loss for Robust Facial Landmark Localisation with Convolutional Neural Networks》
【学习笔记】反向误差传播之数值微分
图像增强的几个方法以及Matlab代码
【FastDepth】《FastDepth:Fast Monocular Depth Estimation on Embedded Systems》
随机推荐
Eklavya -- infer the parameters of functions in binary files using neural network
【Random Erasing】《Random Erasing Data Augmentation》
【Programming】
It's great to save 10000 pictures of girls
What if the notebook computer cannot run the CMD command
open3d学习笔记二【文件读写】
【BiSeNet】《BiSeNet:Bilateral Segmentation Network for Real-time Semantic Segmentation》
Rhel7 operation level introduction and switching operation
Yolov3 trains its own data set (mmdetection)
Target detection for long tail distribution -- balanced group softmax
[C # note] the data in DataGridView saved in WinForm is excel and CSV
【Mixup】《Mixup:Beyond Empirical Risk Minimization》
Correction binoculaire
Traditional target detection notes 1__ Viola Jones
Thesis writing tip2
【MnasNet】《MnasNet:Platform-Aware Neural Architecture Search for Mobile》
稀疏矩阵存储
Pointnet understanding (step 4 of pointnet Implementation)
【Programming】
open3d学习笔记五【RGBD融合】