c++pointersfunction-prototypesfunction-parameter

C++ : Meaning of const char*const*


In one of the C++ programs, I saw a function prototype : int Classifier::command(int argc, const char*const* argv)

What does const char*const* argv mean? Is it the same as const char* argv[]? Does const char** argv also mean the same?


Solution

  • No, it's not the same as const char *argv[]. The const prohibits modifications of the dereferenced value at the particular level of dereferencing:

    **argv = x; // not allowed because of the first const
    *argv = y; // not allowed because of the second const
    argv = z; // allowed because no const appears right next to the argv identifier