I have a function that receives float**
as an argument, and I tried to change it to take const float**
.
The compiler (g++
) did
If you converted the parameter to const float**
you could then store a const float*
at the memory location where the parameter points to. But the calling function thinks that this memory location is supposed to contain a non-const float*
and might later try to change this pointed-to float
.
Therefore you cannot cast a float**
to a const float**
, it would allow you to store pointers to constants in locations where pointers to mutable values are expected.
For more details see the C++ FAQ Lite.