gpt4 book ai didi

c++ - 将指针传递给函数

转载 作者:行者123 更新时间:2023-11-28 06:25:31 25 4
gpt4 key购买 nike

我正在学习指针。

int main() {
int a = 2;
cal(&a);
}

void cal(int* a) {
//Here:
//What does the value of a mean?
//What does the value of &a mean?
}

如您所见,在 main() 中,我将 a 的地址传递给函数 cal(int* a)

我想知道 cal(int*) 中的值 a&a 是什么意思?

cal(int*)中的a是否代表main()a的地址?

cal(int*)中的&a只代表main()中指向a地址的地址?

最佳答案

What does the value of &a mean?

获取a的地址。这是通过将地址运算符 & 应用于 int 变量 a 来完成的。

What does the value of a mean?

cal()a 表示调用 cal() 时传递的 int 地址>.

关于c++ - 将指针传递给函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28602724/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com