c++ - Trouble with initializing multidimensional array -
we initialize 2d array this:
int a[2][3] = {{2,3,4},{5,6,7}};
i need initialize 2d array this:
int a[2][3]; a[0] = {2,3,4}; a[1] = {5,6,7};
i.e. want initialize array array. why method fail? should do? or can define a
array of array?
the idea of array keep data in memory contiguous, not achieved approach using, recommend using c style memory management raw memory low level fast, thigh , possibly dangerous solution, or change different data container vector (or others) can add elements similar want , memory still contagious simple array. although depending on size of problem might overkill use vector.
Comments
Post a Comment