网页学习体会

  • 首页
  • 个人博客
您的位置: 首页  >  IT文章  >  const pointer

const pointer

分类: IT文章 • 2024-09-21 10:26:25

经常容易混淆的概念

pointer to const -> 指向的数据不能被修改

const pointer -> 指针的地址不能被修改

int a = 3;
int b = 4;

// read from right to left
const int * p1 = &a;  // a pointer to a const int
int * const p2 = &b;  // a const pointer to an int

*p1 = b; // not OK
p1 = &b; // OK
a = 4; // OK: *p1 = 4

p2 = &a; // not OK
*p2 = a; // OK

reference: http://www.cnblogs.com/haox/p/3177726.html

相关推荐

  • static_cast, dynamic_cast, const_cast讨论
  • let和const
  • C#中的static、readonly与const的比较
  • C/C++中const关键字详解 include "header.h" include "header.h" include "header.h" include "header.h"
  • vue 之 let 和const vue 之 let 和const
  • const { getFieldDecorator } = this.props.form getFieldDecorator报错“Cannot read property 'getFieldDecorator' of undefined”
  • Pointer-Events: 如何处理ScreenTouch和MouseClicks
  • [LeetCode]Copy List with Random Pointer
  • 顶层const和底层const
  • es6 let和const的用法
  • char类型变量二进制形式输出
  • C# 调用C++ SDK/API的问题总结
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

Copyright © 2018-2021   Powered By 网页学习体会    备案号:   粤ICP备20002247号