41 lines
771 B
C++
41 lines
771 B
C++
int main() {
|
|
// const int myConst1;
|
|
const int myConst1 = 100;
|
|
const int myConst2 = 200;
|
|
const int* pMyConst;
|
|
|
|
// init integer
|
|
myConst1 = 100;
|
|
|
|
// init pointer
|
|
pMyConst = &myConst2;
|
|
|
|
// change pointer
|
|
pMyConst = &myConst2;
|
|
|
|
// change integer
|
|
myConst2 = myConst2 + 5;
|
|
|
|
// change integer using pointer
|
|
*pMyConst = myConst1 + 1;
|
|
|
|
int myInt_3;
|
|
int myInt_4 = 400;
|
|
int* const cpMyInt_3 = &myInt_3;
|
|
|
|
// initialize the pointer
|
|
int* const cpMyInt_4;
|
|
int* const cpMyInt_4 = &myInt_4;
|
|
|
|
// initialize integer
|
|
myInt_3 = 300;
|
|
|
|
// change the integer
|
|
myInt_4 = myInt_4 + 5;
|
|
|
|
// change integer using pointer
|
|
*cpMyInt_3 = myInt_4;
|
|
|
|
// change the pointer
|
|
cpMyInt_3 = &myInt_4;
|
|
}
|