Answers

Question and Answer:

  Home  C++ Pointers and Functions

⟩ 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.

 242 views

More Questions for you: