#include<iostream>
using namespace std;
int main()
{
double val = 0;
//cout << " sizeof(val) = " << sizeof(val);
const int ca=30;//常量无法修改
const int* p=&ca;
int* q = const_cast<int*> (p);
*q=10;
cout << " ca = " << ca << " *p = " << *p << " *q = " << *q << endl;
cout << " p = " << p << ", q = " << q << ", &ca = " << &ca << endl;
int ca_100=100; //后面可以修改
const int* p_2=&ca_100;
int* q_2 = const_cast<int*> (p_2);
*q_2 = 200;
cout << "*q_2 = " << *q_2 << ", *p_2 = " << *p_2 << ", ca_100 = " << ca_100;
return 0;
}
ca = 30 *p = 10 *q = 10
p = 0x7fffcac124a4, q = 0x7fffcac124a4, &ca = 0x7fffcac124a4
*q_2 = 200, *p_2 = 200, ca_100 = 200