C++ ---- 指针和引用

本文详细解析了C++中指针的基本概念及其与数组的关系。通过实例讲解了如何定义和使用指针,以及指针与数组之间的相互转换过程。同时探讨了不同情况下指针与数组元素访问的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

the basic of my C++ is so weakness....because i have not go to class about C++ in my university...

wo lost something when i get something....

get to business , this question puzzled me so long time....

today let's analyse it...

the first , 指针...

int *pointer;

int test=100;

pointer=&test;

the value of pointer is the address of  test.

and *pointer=test;

and ....the other

int test=100;

int *pointer=test;  // this say test is int type value...pointer is pointer type value

and this is equal to int *pointer=&test;

and also equal to :

int *pointer;

pointer=&test;

if you change the value of test , the value of pointer not change...

this is 指针...

the second...指针数组

int test[20];

int *pointer=test; or

int *pointer=&test[20]; or

int *pointer; pointer=test;  or

int *pointer; pointer=&test[20];

the value of pointer is the address of a[0]...

then....pay attention to this...

test[i]=*(test+i)=pointer[i]=*(pointer+i);

&test[i]=test+i=&pointer[i]=pointer+i;

and sizeof(test)!=sizeof(*test)...

 tomorrow go on...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值