?
Comment on the following?
Comment on the following?
const int *ptr;
Answer & Solution
Correct Answer:
Option
A
int * : pointer to int
int const * : pointer to const int
int * const : const pointer to int
int const * const : const pointer to const int
Now the first const can be on either side of the type so:
const int * == int const *
const int * const == int const * const
So the above declaration is pointer to const int. Which means,we cannot change the value pointed by ptr.
int const * : pointer to const int
int * const : const pointer to int
int const * const : const pointer to const int
Now the first const can be on either side of the type so:
const int * == int const *
const int * const == int const * const
So the above declaration is pointer to const int. Which means,we cannot change the value pointed by ptr.
Join the Discussion
Login to post a comment or share your explanation.
Login