Answer:
Pointer to constant points to a value that does not change and is declared as:
const type * name
type is data type
name is name of the pointer
e.g: const char *p;
pointer to constant can not be used to change the value being pointed to. Therefore:
char ch = ‘A’;
const char *p = &ch;
*p = ‘B’;
is not allowed. The program will throw an error.
const type * name
type is data type
name is name of the pointer
e.g: const char *p;
pointer to constant can not be used to change the value being pointed to. Therefore:
char ch = ‘A’;
const char *p = &ch;
*p = ‘B’;
is not allowed. The program will throw an error.
Previous Question | Next Question |
What is smart pointer? | What is Pointer Constant? |