#include"stdafx.h"#include<iostream>usingnamespace std;//此处返回局部变量引用 voidtest(constint& b){// b=1000;//常量引用能够防止修改b的值
cout<<"b="<<b<<endl;}/* run this program using the console pauser or add your own getch, system("pause") or input loop */intmain(){int a=10;//int&rel=10;//引用需要一块合法内存空间,故此处错误constint& rel=100;//常量引用,此处相当于 int temp=10;int& rel=temp;test(a);system("pause");return0;}