* a是指针a,那么什么是**? [英] *a is pointer a, so what is **a ?
本文介绍了* a是指针a,那么什么是**?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
* a是指针a,那么什么是**?
帮助我!
*a is pointer a, so what is **a ?
Help me !
推荐答案
这个 [ ^ ]帮助?
在声明中:
In the statement:
int *p;
p
是一个指针(不是 * p
)
变量声明可以解释如下:
* p是一个int,因此p是指向int的指针。
类似的推理给出了
p
is a pointer (not *p
)
The variable declaration may be interpreted as follows:
*p is an int, hence p is a pointer to an int.
A similar reasoning gives
int ** q;
q
是指向 int
的指针。
一般来说,表达式没有上下文,无法正确解释* a
, ** a
。
例如,声明
q
is a pointer to a pointer to an int
.
Generally speaking, the expressions *a
, **a
cannot be interpreted correctly without context.
For instance, the statement
printf("%d\n"), **q);
(如果正确)告诉我们 q
是一个双指针。
实际上,* a
在语法上只有a
本身就是一个指针,在这种情况下* a
不能a
只是因为类型不匹配,无论什么类型a
被定义为指向。
您可能意味着用于定义(指针)变量的语法:
Actually,*a
is only syntactically correct ifa
itself is a pointer, and in that case*a
can not bea
simply because the types don't match, no matter what typea
is defined to point to.
What you probably mean is the syntax used to define a (pointer) variable:
int f1() {
int a; // this is a variable of type int
a = 1;
return a; // this will return the value 1
}
void f2() {
int *a; // this is a pointer to a value of type int
int b;
a = &b; // now a points to the contents of b
b = 2;
return *a; // returns the value of b, which is 2
}
void f3() {
int **a; // this is a pointer to a pointer to a value of type int
int *b;
int c = 3;
b = &c; // ok, b points to the contents of c
a = &b; // a now points to the contents of b which points to the contents of c
return **a; // returns 3
}
这篇关于* a是指针a,那么什么是**?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文