The modifier constin C ++ in front of the star means that with this pointer the specified value cannot be changed, and the pointer itself can point to something else. In the below
void justloadme(const int **ptr)
{
*ptr = new int[5];
}
int main()
{
int *ptr = NULL;
justloadme(&ptr);
}
justloadme the function should not allow editing the integer values (if any) indicated by the passed parameter, whereas it can edit the int * value (since const is not after the first star), but why am I getting a compiler error in both GCC and VC ++ ?
GCC error :: invalid conversion from int**toconst int**
Error VC ++: C2664: "justloadme": it is not possible to convert parameter 1 from "int **" to "const int **". Conversion loses qualifiers
, ? const? , strlen(const char*), const const char*