Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
743 views
Welcome To Ask or Share your Answers For Others

1 Answer

From the C++ Super-FAQ:

Read the pointer declarations right-to-left.

  • const X* p means "p points to an X that is const": the X object can't be changed via p.
  • X* const p means "p is a const pointer to an X that is non-const": you can't change the pointer p itself, but you can change the X object via p.
  • const X* const p means "p is a const pointer to an X that is const": you can't change the pointer p itself, nor can you change the X object via p.

And, oh yea, did I mention to read your pointer declarations right-to-left?

const char * const * is the same as char const * const *: a (non-const) pointer to a const pointer to a const char.

const char * is the same as char const *: a (non-const) pointer to a const char.

const char * * is the same as char const * *: a (non-const) pointer to a (non-const) pointer to a const char.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...