C++
Programming and Technical
Programming
Technical
Differentiate between a constant pointer and pointer to a
constant?
Read Solution (Total 2)
-
- Constant Pointers
constant pointer is a pointer that cannot change the address its holding. In other words, we can say that once a constant pointer points to a variable then it cannot point to any other variable.
example declaration:
int * const ptr;
Pointer to Constant
These type of pointers can change the address they point to but cannot change the value kept at those address.
example of definition could be :
const int* ptr;
- 10 years agoHelpfull: Yes(1) No(0)
- if u imagine precisely ..both will look same ..see in the case f the first it cant point to others means it cant change the value of that location (in perspective f pointer)..in the 2nd case u cant change the value but can point to others but whaTS THE BENEFIT If it points ,,because pointing other means changing the value into which it points
- 9 years agoHelpfull: Yes(0) No(0)
C++ Other Question