I wanted to declare a 2D array and assign values to it, without running a for loop.
I thought I could used the following idea
int array[5] = {1,2,3,
One alternative is to represent your 2D array as a 1D array. This can make element-wise operations more efficient. You should probably wrap it in a class that would also contain width and height.
Another alternative is to represent a 2D array as an std::vector
. This will let you use STL's algorithms for array arithmetic, and the vector will also take care of memory management for you.