I create a dynamic array of pointers like so:
int ** A;
A = new int*[10];
How do I create a dynamic array of const pointers? Where does the const go?
I create a dynamic array of pointers like so:
int ** A;
A = new int*[10];
How do I create a dynamic array of const pointers? Where does the const go?
Courtesy of cdecl.org:
A = new int * const bar[10];
That will give you an array 10 long of pointers that can't be set to anything. You should also declare A as:
int * const *A;
Otherwise you'll have const casting problems.
Or perhaps you want an array of 10 pointers to constant int:
a = new const int *a[10];
const objects must be initialized at declaration.