When used with variables, the const keyword in C++ specifies that the value of the variable cannot be changed after initialization. However, the position of the const keyword matters in a pointer's declaration.
We have 2 char arrays:
char hello[] = "Hello";
char world[] = "World";
Let's initialize 2 pointers to above arrays. Note that one is const char*
and the other is char* const
:
const char* ptrHello = hello;
char* const ptrWorld = world;
Choose all the operations below that are valid (check Explanations for explanation of correct answer):