当前位置:网站首页>常量指针和指针常量
常量指针和指针常量
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 指针的本质是 指针常量 指针的指向不可以修改
边栏推荐
- 针对tqdm和print的顺序问题
- How to turn on night mode on laptop
- 【MagNet】《Progressive Semantic Segmentation》
- 利用Transformer来进行目标检测和语义分割
- 【TCDCN】《Facial landmark detection by deep multi-task learning》
- Open3d learning note 4 [surface reconstruction]
- 【学习笔记】反向误差传播之数值微分
- 【Sparse-to-Dense】《Sparse-to-Dense:Depth Prediction from Sparse Depth Samples and a Single Image》
- open3d学习笔记二【文件读写】
- 【AutoAugment】《AutoAugment:Learning Augmentation Policies from Data》
猜你喜欢

【Sparse-to-Dense】《Sparse-to-Dense:Depth Prediction from Sparse Depth Samples and a Single Image》

将恶意软件嵌入到神经网络中

【MobileNet V3】《Searching for MobileNetV3》

Pointnet understanding (step 4 of pointnet Implementation)

Nacos service registration in the interface

Thesis writing tip2

【FastDepth】《FastDepth:Fast Monocular Depth Estimation on Embedded Systems》

I'll show you why you don't need to log in every time you use Taobao, jd.com, etc?

Replace self attention with MLP

【Paper Reading】
随机推荐
【双目视觉】双目矫正
[Sparse to Dense] Sparse to Dense: Depth Prediction from Sparse Depth samples and a Single Image
Timeout docking video generation
[learning notes] numerical differentiation of back error propagation
open3d学习笔记四【表面重建】
用MLP代替掉Self-Attention
【Mixup】《Mixup:Beyond Empirical Risk Minimization》
How do vision transformer work? [interpretation of the paper]
最长等比子序列
Open3D学习笔记一【初窥门径,文件读取】
Network metering - transport layer
Daily practice (19): print binary tree from top to bottom
Comparison of chat Chinese corpus (attach links to various resources)
EKLAVYA -- 利用神经网络推断二进制文件中函数的参数
(15) Flick custom source
Summary of open3d environment errors
Solve the problem of latex picture floating
Business architecture diagram
Deep learning classification Optimization Practice
【雙目視覺】雙目矯正