const int* p
若纠结于const int* p,int const* p,int* const p这三个指针,可以看视频
本文只用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的更多相关文章
- 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 ...
- int *const && int const * && const int *的区别
ANSIC允许声明常量,常量和变量不同,常量就是不可以改变的量,用关键字const来修饰 比如:const int a int const a 以上两种声明方式是一样的,我们不需要考虑const和in ...
- const int *
5.Please choose the right statement about constusage: A.const int a;//const interger B.int const a;/ ...
- const int * p 和 int const * p 和 int * const p 的区别
首先注意,const int * p 和int const *p 是一样的,并且不管是不是*p,即使const int i和int const i也是一样的,所以我们接下来只讨论int const * ...
- 对于这个函数const int func(const int& a) const声明中,三个const分别是什么意思?
第一个const 函数的返回值类型是const. 这个const修饰没什么意义,你可以想象一下: 既然是函数的 返回值,而且是值传递的形式,是否const有什么意义.如果指针(引用)传递,怎表示返回值 ...
- 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 ...
- Undefined symbols for architecture i386: "MyGetOpenALAudioData(__CFURL const*, int*, int*, int*)"
今天把apple developer上的例子程序oalTouch中的MyOpenALSupport.h和MyOpenALSupport.c添加到自己的工程中,并在另一个文件xxx.cpp里调用,结果出 ...
- const int *p与int *const p的区别(转:csdn,suer0101)
本文只是一篇学习笔记,是看了<彻底搞定C指针>中的相关篇幅后的一点总结,仅此而已! 一.先搞清const int *p与int const *p的区别 它们的区别就是:没有区别!! 无论谁 ...
- int * const 与 const int * 的区别
type * const 与 const type * 是在C/C++编程中特别容易混淆的两个知识点,现在就以 int * const 和 const int * 为例来简略介绍一下这两者之间的区别. ...
- const int * pi/int * const pi的区别
前面有一篇文章:数组名就是常量指针 参考文章:http://blog.pfan.cn/whyhappy/5164.html const int * pi .int const * pi与int * ...
随机推荐
- GC(Garbage Collection)
GC(Garbage Collection) GC背景 创建对象会消耗内存,如果不回收对象占用的内存,内存使用率会越来越高,最终出现OutOfMemoryError(OOM) 在C++中专 ...
- PAT甲级 二叉树 相关题_C++题解
二叉树 PAT (Advanced Level) Practice 二叉树 相关题 目录 <算法笔记> 重点摘要 1020 Tree Traversals (25) 1086 Tree T ...
- python 正则 re模块(详细版)
正则表达式 什么是正则表达式? 正则表达式是对字符串(包括普通字符(例如,a 到 z 之间的字母)和特殊字符(称为“元字符”))操作的一种逻辑公式,就是用事先定义好的一些特定字符.及这些特定字符的组合 ...
- Python笔记004-Python最基本内置数据类型和运算符
第二章(1)Python编程基础概念 1. 最基本内置数据类型和运算符 每个对象都有类型,Python 中最基本的内置数据类型: 1. 整数 整数,2345 ,10 ,50 2. 浮点型 小数,3.1 ...
- SAS学习笔记31 SAS随机分组方法及实现
随机分组方法包括: 简单随机化(simple randomization) 区组随机化(block randomization) 分层随机化(stratified randomization) 分层区 ...
- 列表初始化(list initialization)
列表初始化啊就是大括号来初始化: 列表初始化的好处:
- Kubernetes 学习笔记(五):数据卷
"数据卷"通常和"有状态"这个词同时出现,卷用于给有状态应用保存/共享状态. 常用的数据卷类型 1. emptyDir: 用于存储临时数据的空目录 emptyD ...
- (四)网格(dataGrid)
一.普通网格 前端index.jsp <%@ page language="java" contentType="text/html; charset=UTF-8& ...
- ASP.NET Core 中的脚本标记帮助程序
官网地址:https://docs.microsoft.com/zh-cn/aspnet/core/mvc/views/tag-helpers/built-in/script-tag-helper?v ...
- HTTP协议 学习
HTTP是hypertext transfer protocol(超文本传输协议)的简写,它是TCP/IP协议的一个应用层协议,用于定义WEB浏览器与WEB服务器之间交换数据的过程.客户端连上web服 ...