引用

#include<iostream>


int main()
{
	//变量的引用
	int b = 13;
	int& c = b;
	int& d = c;

	//常量的引用必须是const
	const int & a = 12;

	std::cout << a << ' ' << c << ' ' << d << std::endl;

	//一维数组的引用
	int arr[10];
	int(&p)[10] = arr;

	p[2] = 15;

	std::cout << arr[2] << std::endl;

	//多维数组的引用

	int arr1[3][4];
	int(&p2)[3][4] = arr1;

	p2[1][2] = 16;

	std::cout << arr1[1][2] << std::endl;

	//指针的引用
	int e = 17;
	int* point = &e;

	int* &f = point;

	*f = 18;

	std::cout << *point << std::endl;

	
	system("pause");
	return 0;
}

 

posted @ 2018-04-19 09:22  *夜空中最亮的星*  阅读(108)  评论(0编辑  收藏  举报