编辑代码

#include<iostream>
using namespace std;
void ConstTest1(){
    const int a = 1;
    int *p;
    p = const_cast<int*>(&a);
    (*p)++;
    cout<<a<<endl;
    cout<<*p<<endl;
    
}
void ConstTest2(){
    int i=3;
    const int a = i;
    int*r = const_cast<int*>(&a);
    (*r)++;
    cout<<a<<endl;

    cout<<*r<<endl;
}
void ConstTest3(){
    
    const int a = 1;
    int& r = const_cast<int&>(a);
    (r)++;
    cout<<a<<endl;

    cout<<r<<endl;
}
int main(){
    ConstTest1();
    ConstTest2();
     ConstTest3();

    return 0;
}