引用是一种复合类型,通过在变量名前添加“&”符号来定义。
引用只是对象的另一个名字
int iVal = 1024;
int &refVal = iVal;
refVal++;
cout << iVal << endl; //1025
const引用
const int iVal = 1024;
const int &refVal = iVal;
引用是一种复合类型,通过在变量名前添加“&”符号来定义。
引用只是对象的另一个名字
int iVal = 1024;
int &refVal = iVal;
refVal++;
cout << iVal << endl; //1025
const引用
const int iVal = 1024;
const int &refVal = iVal;
上一篇:【c++】C风格字符串
C++入门知识,包括命名空间,引用,函数重载等。
引用的基本使用
C++特性 引用
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M