若纠结于const int* p,int const* p,int* const p这三个指针,可以看视频

https://www.icourse163.org/learn/BUPT-1003564002?tid=1206737208#/learn/content?type=detail&id=1211907686&cid=1214929609

本文只用const int* p,其他不使用,也不纠结了。

int* p 只能指向变量,可读可写。

const int* p 只读指针,可以指向变量、常量等,只读。

    int x{  }, y{};
const int cx{ }, cy{ };
int* p;//只能指向变量,可读可改。
const int* cp;//只读指针。可以指向常量、变量,但是只读,不可更改。 p = &x;//指针p指向地址x
p = &y;//指向地址y
//p = &cx;//错误,
*p = ;//改变地址y中的值
cp = &x;
cp = &y;
cp = &cx;
cp = &cy;
//*cp = 30;//错误

const int* p的更多相关文章

  1. the difference between const int *, int * const, int const *

    Some people may be confused about the sequence of const and * on declaration in C++/C, me too. Now I ...

  2. int *const && int const * && const int *的区别

    ANSIC允许声明常量,常量和变量不同,常量就是不可以改变的量,用关键字const来修饰 比如:const int a int const a 以上两种声明方式是一样的,我们不需要考虑const和in ...

  3. const int *

    5.Please choose the right statement about constusage: A.const int a;//const interger B.int const a;/ ...

  4. const int * p 和 int const * p 和 int * const p 的区别

    首先注意,const int * p 和int const *p 是一样的,并且不管是不是*p,即使const int i和int const i也是一样的,所以我们接下来只讨论int const * ...

  5. 对于这个函数const int func(const int& a) const声明中,三个const分别是什么意思?

    第一个const 函数的返回值类型是const. 这个const修饰没什么意义,你可以想象一下: 既然是函数的 返回值,而且是值传递的形式,是否const有什么意义.如果指针(引用)传递,怎表示返回值 ...

  6. caffe: compile error : undefined reference to `cv::imread(cv::String const&, int)' et al.

    when I compile caffe file : .build_debug/lib/libcaffe.so: undefined reference to `cv::imread(cv::Str ...

  7. Undefined symbols for architecture i386: "MyGetOpenALAudioData(__CFURL const*, int*, int*, int*)"

    今天把apple developer上的例子程序oalTouch中的MyOpenALSupport.h和MyOpenALSupport.c添加到自己的工程中,并在另一个文件xxx.cpp里调用,结果出 ...

  8. const int *p与int *const p的区别(转:csdn,suer0101)

    本文只是一篇学习笔记,是看了<彻底搞定C指针>中的相关篇幅后的一点总结,仅此而已! 一.先搞清const int *p与int const *p的区别 它们的区别就是:没有区别!! 无论谁 ...

  9. int * const 与 const int * 的区别

    type * const 与 const type * 是在C/C++编程中特别容易混淆的两个知识点,现在就以 int * const 和 const int * 为例来简略介绍一下这两者之间的区别. ...

  10. const int * pi/int * const pi的区别

    前面有一篇文章:数组名就是常量指针 参考文章:http://blog.pfan.cn/whyhappy/5164.html const int * pi .int const * pi与int *   ...

随机推荐

  1. java中不常见的关键字:strictfp

    1.strictfp, 即 strict float point (精确浮点). strictfp 关键字可应用于类.接口或方法.使用 strictfp 关键字声明一个方法时,该方法中所有的float ...

  2. 整合thymeleaf

    1.导入thymeleaf依赖 2.controller类 (1)模板 导入命名空间,xmlns:th="http://www.thymeleaf.org" (2)ModelAnd ...

  3. Python创建线程

    Python 提供了 _thread 和 threading 两个模块来支持多线程,其中 _thread 提供低级别的.原始的线程支持,以及一个简单的锁,正如它的名字所暗示的,一般编程不建议使用 th ...

  4. WebElement的方法:

    这个类代表HTML页面元素 id_ #当前元素的ID tag_name #获取元素标签名的属性 text #获取该元素的文本. click() #单击(点击)元素 submit() #提交表单 cle ...

  5. 浅谈人脸识别中的loss 损失函数

    浅谈人脸识别中的loss 损失函数 2019-04-17 17:57:33 liguiyuan112 阅读数 641更多 分类专栏: AI 人脸识别   版权声明:本文为博主原创文章,遵循CC 4.0 ...

  6. (十五)Hibernate中的多表操作(5):双向多对多

    Hibernate的双向关联. 对象之间可以相互读取.        双向只针对读取的操作.对于增.删除.改的操作没有任何影响. 案例 : 实现双向多对多 MenuBean.java package ...

  7. oracle学习笔记:update一整列 关联更新

    普通的 update 都是根据条件来对部分列的内容进行修改,用法如下: update temp_cwh_table set name = 'xxx' where id = 1; 假设现在有2张表:A. ...

  8. docker系列七之Dockerfile

    Dockerfile 一. Dockerfile是什么   Dockerfile是docker中镜像文件的的描述文件,说的直白点就是镜像文件到底是由什么东西一步步构成的.例如我们在淘宝上买了一件商品, ...

  9. oracle exists和 not exists 的用法

    比如 a,b 关联列为 a.id = b.id,现在要取 a 中的数据,其中id在b中也存在: select * from a where exists(select 1 from b where b ...

  10. 【Hibernate】抓取策略

    一.区分延迟和立即检索 二.类级别检索和关联级别检索 一.区分延迟和立即检索 立即检索: 当执行某行代码的时候,马上发出SQL语句进行查询. get() 延迟检索: 当执行某行代码的时候,不会马上发出 ...