C++ Pointers & Functions Question:
Download Questions PDF

What is Pointer to constant?


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.

Download C++ Pointers & Functions Interview Questions And Answers PDF

Previous QuestionNext Question
What is smart pointer?What is Pointer Constant?