1#include <iostream>
2using namespace std ;
3int main(void)
4{
5 int obj1 = 33;
6 int obj2 = 66;
7 int *const cp_nci = &obj1; // const pt point to nonconst int
8 *cp_nci = 56; // can modify
9 //cp_nci = &obj2; // cannot modify
10 cout<<cp_nci<<" "<<*cp_nci<<endl;
11
12 int const *ncp_ci ; //non const pt point to const int
13 ncp_ci = &obj1; // needn't be initialized
14 //*ncp_ci = 12; // cannot modify
15 ncp_ci = &obj2; // can modify
16 cout<<ncp_ci<<" "<<*ncp_ci<<endl;
17
18 int const *const cp_ci = &obj1 ; //const pt point to const int
19 //*cp_ci = 90; // cannot modify
20 //cp_ci = &obj2 ; // cannot modify
21 cout<<cp_ci<<" "<<*cp_ci<<endl;
22
23}
24
2using namespace std ;
3int main(void)
4{
5 int obj1 = 33;
6 int obj2 = 66;
7 int *const cp_nci = &obj1; // const pt point to nonconst int
8 *cp_nci = 56; // can modify
9 //cp_nci = &obj2; // cannot modify
10 cout<<cp_nci<<" "<<*cp_nci<<endl;
11
12 int const *ncp_ci ; //non const pt point to const int
13 ncp_ci = &obj1; // needn't be initialized
14 //*ncp_ci = 12; // cannot modify
15 ncp_ci = &obj2; // can modify
16 cout<<ncp_ci<<" "<<*ncp_ci<<endl;
17
18 int const *const cp_ci = &obj1 ; //const pt point to const int
19 //*cp_ci = 90; // cannot modify
20 //cp_ci = &obj2 ; // cannot modify
21 cout<<cp_ci<<" "<<*cp_ci<<endl;
22
23}
24