C ++指针 - 这里有什么值? [英] C++ pointers - What values are held here?
问题描述
如果我有以下指针变量声明:
int * a;
int ** c;
关于类型和每个值将包含的值如下:
a 的类型为
int *
,并且将保存一个内存地址
* a
类型为 int
,并且将保存指针指向的变量的值
c
int **
,并将保留
c *
的类型为 int *
将保存其指向的指针的内存地址
c **
类型 int
,并且假设指针 c
指向指针 b
b
指向变量 a
,这里,保持的值将是变量 a c>
这样是正确的,除了 c
确定吗?
谢谢。
int * a;
int ** c;
您对 a
正确。更常见的是 a 持有指向int 的
指针。
c 的类型为
int **
,并且将保存一个指向int
。
* c
int * ,并且将保存指向int 的指针。
** c
的类型为 int
,并且将保存一个整数值。您对 c
指向 b
和 b
指向 > cdecl 一些帮助。 :)
If I have the following pointer variable declarations:
int *a;
int **c;
Regarding to the type and what values each will hold, will it be as follows:
a
is of type int*
, and will hold a memory address
*a
is of type int
, and will hold the value of the variable the pointer is pointing to
c
is of type int**
, and will hold ?????????????????????
c*
is of type int*
, and will hold the memory address of the pointer it is pointing at
c**
is of type int
, and assuming that pointer c
is pointing to pointer b
, and pointer b
is pointing to variable a
, here, the value held will be the value of the variable a
Is it correct this way, except c
which I'm not sure about?
Thanks.
int *a;
int **c;
You are correct about a
. It is more common to say a
holds a pointer to int
.
c
is of type int**
and will hold a pointer to a pointer to int
.
*c
is of type int*
, and will hold a pointer to int
.
**c
is of type int
, and will hold an integer value. You are correct about c
pointing to b
and b
pointing to a
.
See cdecl for some help. :)
这篇关于C ++指针 - 这里有什么值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!