C ++指针 - 这里有什么值? [英] C++ pointers - What values are held here?

查看:103
本文介绍了C ++指针 - 这里有什么值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有以下指针变量声明:


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屋!

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