类型& 引用变量名称 = 变量名称;
这就是引用变量的定义。&和类型结合称之为引用符号,不是取地址的符,是代表别名的意思。
1、引用和指针
void Swap_int(int& ap, int& bp)
{
int tmp = ap;
ap = bp;
bp = tmp;
}
void Swap_int(int* ap, int* bp)
{
assert(ap != NULL && bp != NULL);
int tmp = *ap;
*ap = *bp;
*bp = tmp;
}
int main()
{
int a