#include
using namespace std;
void change_value(int &a ){
a=100;
}
void assign_value(int (&arr)[10]){
arr[5]=777;
}
int &return_refer(int &a){
//int a =333;
return a;
}
int main(int argc,char const *argv[])
{
//仅定义,未初始化
int a=999;
int b=10;
//define a reference,also give another name.So define a reference must be initilized
int &r=a;
int *p=&a;
//quote will not ask an extra memory,but pointer needs to ask for an extra memory
//quote needs an extra settle quote operation but quote doesn’t need to
cout<<*p<<endl;
cout<<r<<endl;
cout<<a<<endl;
change_value(a);
cout<<a<<endl;
int arr[10]={0};
assign_value(arr);
cout<<arr[5]<<endl;
cout<<return_refer(a)<<endl;
return 0;
}
运行结果