I know that this topic has been discussed in other posts, but I have an additional question concerning the case when you want to pass a nested new created array as const.
For example:
1.- we create the 2 dimension array, like this (there are others way to do it, but I would like to discuss this):
int **q;
q=new int *[3];
for (int i=0;i<3;i++){
q[i]=new int[3];
}
2.- then you have a function that will recive the 2D matrix q as “const”:
If you don't want the integer values changed, you would void func(constint ** q); if you would like to keep the function from altering the pointers to the arrays inside the array you would void func(int * const * q); finally, to merge the two previous cases you would void func(constint * const * q).
But the first option you mention const int **q (actually this is the option I am interested in) does not work (my compiler does not admit it, MSC C++ compiler); I tried it time ago but it really does not work