当前位置:网站首页>常量与常量指针
常量与常量指针
2022-07-17 05:08:00 【学会放下ta】
常量
一般常量数字,字符,字符串
当用const修饰变量后可以把变量变为常量
const double pi = 3.14;
pi = 3.1415926;//如果你想修改值pi,则会报错
指向常量的指针
由上可知:用const修饰的指针就是指向常量的指针,不可通过解引用来修改其值。
const int a = 520;
const int *p = &a;
*p = 123;//会报错
但是此时可以修改指针p的指向。与之相反,有
常量指针
意为指针的指向不可改变,如果其指向的是变量则可改变其值,若是常量则不可改变。
int a = 123;
int b = 520;
int * const p = &a;
*p = 111;//作用后a的值被改为111
p = &b;//会报错,因为指针的指向是固定的
指向常量的常量指针和指向常量的常量指针的指针
const int num = 111;
const int * const p = #//指向常量的常量指针
const int * const *pp = &p;//指向常量的常量指针的指针
边栏推荐
- SQL injection
- 云服务器部署WEB项目
- 父组件加scoped有时也会影响子组件
- C语言的高级操作
- [first launch in the whole network] automatic analysis of JVM performance problems
- What is the employment prospect of software testing? There is a large demand for talents and strong job stability
- 软件测试就业前景怎样 人才需求大,岗位稳定性强
- Talk about 20 negative teaching materials for writing code
- Flex弹性布局
- ambari集群扩容节点+扩容服务操作
猜你喜欢

新手学习渗透测试的入门指南

路由器loopback口实验

ambari集群扩容节点+扩容服务操作

基于libco的协程实现6 libcurl的同步接口的实现方案

Talk about 12 business scenarios of concurrent programming

用户态协议栈-基于netmap的UDP实现

Teach you to reproduce log4j2 nuclear weapon level vulnerability hand in hand

Parent components plus scoped sometimes affect child components

Cesium 綁定鼠標事件和移除鼠標事件

Swagger配置与使用
随机推荐
2020-11-10
【全网首发】JVM性能问题的自动分析
2020-10-22
Log4j的使用
Solutions for vscode terminal failure
聊聊写代码的20个反面教材
Redis source code analysis - data structure and Implementation (Dictionary dict)
Switch user mode, privileged mode, global mode, port mode
mysql - 索引
Two or three things to know about operation and maintenance safety
【AI】利用简单神经网络做动作识别——基于coco关键点
[first launch in the whole network] one month later, we switched from MySQL dual master to master-slave
聊聊并发编程的12种业务场景
MySQL - index
Distributed storage fastdfs
路由器loopback口实验
mysql 缓存策略和解决方案
新手学习渗透测试的入门指南
Easypoi之excel模板导出
H5 page uses JS to generate QR code