//引用是变量的别名,而且引用不能单独存在
#include <iostream>
using namespace std;
typedef struct A
{
int x;
int y;
}co;
void fun(int &a, int &b)
{
int c = 0;
c = a;
a = b;
b = c;
return;
}
int main()
{
//结构体的引用
co c;
co &c1 = c;
c1.x = 10;
c1.y = 10;
cout << c.x << "," << c.y << endl;
//函数参数的引用
int x = 10, y = 20;
fun(x, y);
cout << x << "," << y << endl;
//基本数据类型的引用
int a = 10;
int &b = a;
cout << b << endl;
//指针引用
int *p = &a;
int *&q = p;
cout << *q << endl;
system("pause");
return 0;
}