引用的本质在C++的内部是指针常量
//发现是引用,转换为 int * const ref = &a;
void func(int& ref){
ref = 100; // ref是引用,转化为 int*ref = 100;
}
int main(){
int a = 10;
//自动转换为int* const ref = &a; 指针常量是指针指向不可改,也说明为什么引用不可更改
int & ref = a;
ref = 20;
cout << a << endl;
cout << ref << endl;
func(a);
return 0;
}