2D array vs array of arrays(二维数组与数组数组)
问题描述
二维数组和数组数组有什么区别?
What is the difference between a 2D array and an array of arrays?
我已阅读评论,例如 @Dave's,这似乎区分了两者.
I have read comments, such as @Dave's, that seem to differentiate between the two.
如果他使用二维数组或指向数组的类型,而不是数组的数组,这会中断.– 戴夫
This breaks if he's using 2d arrays, or pointer-to-array types, rather than an array of arrays. – Dave
我一直认为两者都指的是:
I always thought that both referred to:
int arr_arr[][];
<小时>
@FutureReader,您可能希望看到 如何在 C++ 中使用数组?
@FutureReader, you may wish to see How do I use arrays in C++?
推荐答案
二维数组是定义为数组的数组.
A 2 dimensional array is by definition an array of arrays.
Dave 所说的是,在这种情况下,像这样的二维数组定义之间存在不同的语义:
What Dave was saying is that in that context, there are different semantics between the definition of a 2D array like this:
int x[][];
这个:
int *x[];
或者这个:
int **x;
这篇关于二维数组与数组数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:二维数组与数组数组
基础教程推荐
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 初始化列表*参数*评估顺序 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- CString 到 char* 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
