C++ Pointers & Functions Question:
Download Questions PDF

What is const pointer?

Answer:

const pointer is a pointer which you don’t want to be pointed to a different value. That is, the location stored in the pointer can not change. We can not change where the pointer points. It is declared as:

type * const name
type is data type
name is name of the pointer
eg: char * const p

Since the location to which a const pointer points to can not be changed, the following code:

char ch1 = ‘A’;
char ch2 = ‘B’;
char * const p = &ch1;
p = &ch2;
will throw an error since address stored in p can not be changed.

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

Previous QuestionNext Question
What is const reference?Where does the execution of the program starts?
a) user-defined function
b) main function
c) void function
d) none of the mentioned