【c++】引用

引用是一种复合类型,通过在变量名前添加“&”符号来定义。

引用只是对象的另一个名字

int iVal = 1024;
int &refVal = iVal;
refVal++;
cout << iVal  << endl; //1025

const引用

const int iVal = 1024;
const int &refVal = iVal;

 

posted @ 2021-08-18 09:13  王牌飞行员_里海  阅读(192)  评论(0编辑  收藏  举报