This question already has an answer here:
I have an array whose size is set using a compile-time constant (a pre-processor #define in my case). I need to initialize it using consecutive numbers. How can I do this?
Simplified example:
#define ARR_SZ = 5
int arr[ARR_SZ] = {0,1,2,3,4}; // This needs to adapt to any number
I can use C++11, but not newer (although I would be interested to learn of newer techniques even if I can't use them for this project)
Aucun commentaire:
Enregistrer un commentaire