数组的地址 [英] Address of array

查看:152
本文介绍了数组的地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int t[10];

int * u = t;

cout << t << " " << &t << endl;

cout << u << " " << &u << endl;

输出:

0045FB88 0045FB88
0045FB88 0045FB7C

U 输出是有道理的。

据我所知, T &amp; T公司[0] 应具有相同的价值,但怎么来的&amp; T公司也是一样的吗? &是什么放大器;?吨实际上意味着

I understand that t and &t[0] should have the same value, but how come &t is also the same? What does &t actually mean?

推荐答案

T 在EX pression用于自身,一个数组用于─指针转换发生,这将产生一个指针数组的第一元素

When t is used on its own in the expression, an array-to-pointer conversion takes place, this produces a pointer to the first element of the array.

T 被用作&放大器的参数; 运营商,没有这样的转换发生。在&安培; 则明确采取 T 的地址(阵列)。 &放大器;:T 是一个指向数组作为一个整体

When t is used as the argument of the & operator, no such conversion takes place. The & then explicitly takes the address of t (the array). &t is a pointer to the array as a whole.

阵列的第一个元素是在存储器中的相同位置的整个阵列的开始,所以这两个指针的值相同。

The first element of the array is at the same position in memory as the start of the whole array, and so these two pointers have the same value.

这篇关于数组的地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆