How to build 5d array in C++

If I want to have Arr [const][variable][const][variable][const], what should I do?

  1. Use 5-layer typedef

typedef int A1 [9];

typedef A1 *A2;

typedef A2 A3[8];

typedef A3 *A4;

typedef A4 A5 [7];

int main()

{

A5* x;

return 0;

}

2. Use only one typedef

typedef int(*(*(*B[7])[8])[9])

int main()

{

B y = 0;

}

One thought on “How to build 5d array in C++”

Leave a Reply

Your email address will not be published. Required fields are marked *