当前位置:网站首页>const修饰指针的三种情况
const修饰指针的三种情况
2022-08-09 23:15:00 【leimingzeOuO】
const修饰指针有三种情况
- const 修饰指针-常量指针
- const 修饰常量-指针常量
- const即修饰指针,又修饰常量
void solve()
{
int a=10,b=20;
//const 修饰的是指针,指针指向可以改变,指针指向的值不可以改变
const int *p=&a;
p=&b;//yes
//*p=100;//no
cout<<*p<<endl;
//const 修饰的是常量,指针指向不可以改变,指针指向的值可以改变
int *const p2=&a;
//p2=&b;//no
*p2=100;//yes
cout<<*p2<<endl;
//const 既修饰指针又修饰常量
const int *const p3=&a;
//p3=&b;//no
//*p3=100;//no
}
边栏推荐
- 信息系统项目管理师核心考点(六十四)信息安全基础知识重要概念
- CST Studio Suite 2021软件安装包和安装教程
- 【剑指offer】第一题 第二题
- 为什么不建议你在 Docker 中跑 Mysql ?
- framework源码读后感
- Dry goods!Towards robust test-time adaptation
- 漫谈缺陷管理的自动化实践方案
- 【obs】obsqsv11 硬编 及与metartc codec对比
- conda新建环境时报错NotWritableError: The current user does not have write permissions
- 恭喜获奖得主 | 互动有礼获赠 Navicat Premium
猜你喜欢
随机推荐
多商户商城系统功能拆解24讲-平台端分销会员
服务发现@EnableDiscoveryClient
【集训DAY4】异或【字典树】
直播平台怎么搭建,原生js实现编辑器撤消/恢复功能
Travel with Shengteng: See all the AI attractions in Jinling City in one day
【集训DAY5】堆箱子【数学】
[Cloud native] Kubernetes orchestration tools
源码编译安装LAMP和LNMP
直播app开发搭建,flutter 实现自适应、自动换行、相对布局
数字钱包红海角逐,小程序生态快速引入可助力占领智慧设备入口
【诗歌】最高级的惩罚就是沉默
二进制、八进制、十进制、十六进制之间的转换
【剑指offer】第一题 第二题
【集训DAY4】询问【Hash】
网络协议05 -网络层
SRv6 performance measurement
AirFlow介绍
New window Display Agreement
AppUser object extension based on ABP
Eureka protects itself