//引用做函数的返回值 //引用是可以作为函数的返回值存在的 #includeusing namespace std; //不要返回局部变量的引用!!! //函数的调用可以作为左值!!! int& test01() { int a = 10; //局部变量存放在四区当中的栈区 return a; } int& test02() { static int a = 10; //静态变量 存放在全局区 //全局区上的数据在程序结束后系统释放 return a; //这里的a并不会因为test02()执行完成以后被释放 //而是会在程序结束后被系统释放 } int main() { // int &ref = test01(); // cout< //引用的本质 就是一个指针常量 //引用初始化之后 就不可以发生改变 #includeusing namespace std; //发现是引用 转换为 int* const ref = &a; void fun(int& ref) { ref = 190;//ref 是引用 转换为*ref=190; cout< //常量引用(const) //修饰形参 防止误操作 #includeusing namespace std; void show(const int& a)//加const 是为了不会去修改a { // a = 190; cout<



