const pointer code example
Example 1: const pointer c++
int *p;
const int *p == int const *p;
int * const p;
const int * const p == int const * const p;
Example 2: pointer to constant
#include<iostream>
int main()
{
int number_1{100};
int number_2 {200};
const int *some_ptr {&number_1};
*some_ptr = 300 ;
*some_ptr = &number_2 ;
int *const some_ptr {&number_1} ;
some_ptr = &number_2
*some_ptr = 123
const int const *some_ptr{&number_1};
*some_ptr = 32;
some_ptr = &number_2;
return 0;
}
Example 3: pointer to constant
const int *some_ptr {&number_1};
int *const some_ptr {&number1} ;