快速理解 const int*, const int * const, and int const * 区别
快速 区别 理解 and int const
2023-09-11 14:14:58 时间
Memory Map
One way to remember the syntax (according to Bjarne Stroustrup) is the spiral rule-
The rule says, start from the name of the variable and move clockwise to the next pointer or type. Repeat until expression ends.
The rule can also be seen as decoding the syntax from right to left.
从右往左 遇到 * 或者 type类型为 to 的分隔点
Hence,
- int const* is pointer to const int
- int *const is const pointer to int
- int const* const is const pointer to const int
Using this rule, even complex declarations can be decoded like,
- int ** const is a const pointer to pointer to an int.
- int * const * is a pointer to const pointer to an int.
- int const ** is a pointer to a pointer to a const int.
- int * const * const is a const pointer to a const pointer to an int.
相关文章
- 如何快速的给你的项目添加icon图标
- Java实现快速排序
- Java实现 蓝桥杯VIP 算法提高 快速幂
- 使用Sort方法对数组进行快速排序
- 电脑只有一个磁盘怎么快速分区
- 电力系统潮流计算(牛顿-拉夫逊法、高斯-赛德尔法、快速解耦法)(Matlab代码实现)
- matlab快速入门(12):对向量执行数组运算
- 快速了解前端开发HTML的正确姿势
- 快速掌握用python处理Excel
- 博客园快速转载的方法,复制html的内容直接粘贴
- 矩阵快速幂在ACM中的应用
- 【快速入门大数据】第一部分:Java基础知识回顾之语言基础01:开发环境配置、数据类型、运算符、流程控制
- GreenPlum的学习心得和知识总结(三)|Greenplum数据库快速入门