分享兴趣,传播快乐,增长见闻,留下美好!
亲爱的您,这里是LearningYard新学苑。
今天小编为大家带来“深入C++(四)——指针”,欢迎您的访问。
Share interest, spread happiness, increase knowledge, and leave beautiful.
Dear, this is the LearingYard Academy!
Today, Dive into C++ (iv) -- Pointers,welcome to visit!
一、指针变量
1. Pointer variables
指针变量用于存放数据变量地址,定义指针变量的类型要与该数据变量保持一致,并在后面加上星号。也可以通过星号实现指针的解引用,获取对应地址中存放的值,即数据变量的值。
The pointer variable is used to store the address of the data variable. The type of the pointer variable must be consistent with that of the data variable, and an asterisk should be added after it. The dereference of the pointer can also be achieved through the asterisk to obtain the value stored in the corresponding address, that is, the value of the data variable.
二、所占内存
2. The memory occupied
所有类型的指针占用内存大小都一样,其内存大小由操作系统位数决定,32位占4字节,64位占8字节。
The memory size of all types of Pointers is the same, and the memory size is determined by the operating system bits, 32 bits are 4 bytes, 64 bits are 8 bytes.
三、空指针
3. Null pointer
空指针,指针指向编号位0的内存空间,且改内存空间无法访问。多用于指针的初始化
Null pointer. The pointer points to the memory space numbered bit 0 and the memory space cannot be accessed. Mostly used for pointer initialization
四、野指针
4. Wild pointer
野指针,指针指向非法的内存空间,同样没有访问权限。
Wild pointer, pointer to illegal memory space, also have no access rights.
五、const修饰指针
5. const modifies pointer
在定义指针变量时,通过const修饰指针或数据类型,获得不同的指针类型。
When a pointer variable is defined, different pointer types are obtained by modifying the pointer or data type with const.
今天的分享就到这里了,
如果您对文章有独特的想法,
欢迎给我们留言。
让我们相约明天,
祝您今天过得开心快乐!
That's all for today's sharing.
If you have a unique idea about the article,
please leave us a message,
and let us meet tomorrow.
I wish you a nice day!
翻译:网易有道翻译
本文由LearningYard学苑整理并发出,如有侵权请后台留言沟通.
文案|Dongyang
排版|Dongyang
审核|hong
Learning Yard 新学苑
本文暂时没有评论,来添加一个吧(●'◡'●)