I am reading application code developed in the IBM RSARTE C++ version. Here is a piece of C++ code:
const char * const * av = RTMain::argStrings();
How to understand the left-hand side syntax when there are two const and two *?
>Solution :
const char * const * av = RTMain::argStrings();
is the same as
char const * const * av = RTMain::argStrings();
const applies to what’s left of const.
So, av is a non-const pointer to a const* to const char.
- The returned pointer,
av, is non-constand can be changed. - The pointer
avis pointing at isconstand can not be changed. - The
charthat pointer is pointing at isconstand can not be changed.