Hopefully this question will make sense; if not, please correct my thinking
:)
If I wish to create a one-dimensional array at run time, I write
int * myArray = new int [size];
and pass that array to functions using prototypes
void foo1 ( int * );
or as
void foo2 (const int *);
depending on whether or not I wish the function to be able to modify the
data in the array.
Both of these seem to work just fine.
Now I wish to do the same with int * *. I create the 'table' as
int * * myTable = new int * [rows];
for(int i = 0; i < rows; ++i)
myTable[i] = new int [cols];
and send it to functions with prototypes
void bar1 ( int * *);
or
void bar2 ( const int * *);
Everything works great except that last line: the compilers complain about
"cannot convert from int * * to const int * *; conversion loses qualifiers"
or something to that effect.
How can I send this int * * 'table' to a function in such a way that the
function can't modify the data - that is, send it as const, as I can do with
an int * 'array' ?
Using std::vector instead doesn't answer my question, so please don't
suggest it.
--
John Goulden
jg******@okcu.edu
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]