C++ Pointers & Functions Question: Download C++ Pointers & Functions PDF

What is Pointer to constant?

Tweet Share WhatsApp

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.

Download C++ Pointers & Functions PDF Read All 32 C++ Pointers & Functions Questions
Previous QuestionNext Question
What is smart pointer?What is Pointer Constant?