gpt4 book ai didi

c++ - ELI5 : What is the data type of `int *p[]`

转载 作者:太空狗 更新时间:2023-10-29 23:38:49 25 4
gpt4 key购买 nike

我不明白这是什么数据类型。如果它是一个指针或数组。请简单说明。引用书中的内容-

If you want to pass an array of pointers into a function, you can use the same method that you use to pass other arrays—simply call the function with the array name without any indexes. For example, a function that can receive array x looks like this:

void display_array(int *q[])
{
int t;
for(t=0; t<10; t++)
printf("%d ", *q[t]);
}

Remember, q is not a pointer to integers, but rather a pointer to an array of pointers to integers. Therefore you need to declare the parameter q as an array of integer pointers, as just shown. You cannot declare q simply as an integer pointer because that is not what it is.

引用:C++:完整引用,第 4 版,Herbert Schildt,第 122-123 页

最佳答案

它是这样构建的:

  • int类型“int”。
  • int*类型“指向 int 的指针”
  • int* []类型“指向 int 的指针的数组(未知边界/长度)”
  • int* p[] 是上述类型的名为 p 的变量或参数的声明

关于c++ - ELI5 : What is the data type of `int *p[]` ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53633122/

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