#include <iostream>
using namespace std;
void func1(int& ref){
ref = 100;
}
void func2(int* ref){
*ref = 200;
}
void func3(int ref){
ref = 300;
}
int main() {
int a = 2;
//指针常量: int* const ref = &a, 代表指针指向不可改变;
int& ref = a;
cout << ref << endl;
//传入参数为引用
func1(ref);
cout << a << endl;
func2(&ref);
cout << a << endl;
//传入参数实际为实参的copy版
func3(ref);
cout << a << endl;
return 0;
}