CONST 部分用法
代码块
#include <iostream>
using namespace std;
void main()
{
int a = 1, b = 2, c = 3;
cout << "a = " << a << ", " << "b = " << b << ", " << "c = " << c << endl;
const int *pa = &a;
cout << "pa point to a, pa = " << pa << endl << "*pa : " << *pa << endl;
pa = &b;
cout << "pa point to b, now pa = " << pa << endl << "*pa : " << *pa << endl;
int const *pb = &b;
cout << "pb point to b, pb = " << pb << endl << "*pb : " << *pb << endl;;
pb = &a;
cout << "pb point to a, now pb = " << pb << endl << "*pb : " << *pb << endl;
int *const pc = &c;
cout << "pc point to c, now pc = " << pc << endl << "*pc : " << *pc << endl;
*pc = 10;
cout << "now *pc: " << *pc << endl;
int const d = 4;
const int *pd = &d;
}