c++ - 如何使用 typedef 为 C++ 数组起别名?

标签 c++ c

<分区>

当对数组使用 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/

相关文章:

C++ 安全对象删除

C++ 十六进制字符串到 unsigned int

C++ 复数模板 -/= 运算符

c - 通过 1 个函数用不同的数据类型填充数组

c - C 中的非素数计数器

C HTTP 流媒体服务器流式传输音频分贝级别

c++ - 如何更改参数包中的最后一个参数?

c++ - 错误 LNK2001 : unresolved external symbol for static lib that is loaded

c - 遇到换行符时标记字符串 - 不工作换行符无法被识别

c - 增加数组大小。在 increaseSize 函数之后,同一数组的某些参数无效。铿锵