when using typedef for arrays, it is used as
typedef int Color[3];
it is very counter-intuitive for me.
why not typedef int[3] Color[3]?
typedef looks exactly like a normal vairable declaration, and that happens to be how an array declaration looks in C (and inherited into C++):
int foo[3]; // Array of three int
typedef int FooT[3]; // typedef for array of three int.
Typedef simply works like a varaible definition and follows all the same rules (rules that are already established and known), with the only difference that instead of a variable name it denotes the type.
I would say, rather than implementing some new scheme (that would have to handle all the subtle things like, just for sake of example, pointers to arrays vs. arrays of pointers), using an existing scheme is the sensible choice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With