<分区>
当对数组使用 typedef 时,它被用作
typedef int Color[3];
这对我来说非常违反直觉。
为什么不是 typedef int[3] Color[3]?
<分区>
当对数组使用 typedef 时,它被用作
typedef int Color[3];
这对我来说非常违反直觉。
为什么不是 typedef int[3] Color[3]?
最佳答案
typedef
看起来完全像一个普通的变量声明,这恰好是数组声明在 C 中的样子(并继承到 C++ 中):
int foo[3]; // Array of three int
typedef int FooT[3]; // typedef for array of three int.
关于c++ - 如何使用 typedef 为 C++ 数组起别名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17047502/