C++函数引用

#include <iostream>
using namespace std;

void func(int &a, int &b);

int main(void)
{
	int x = 10;
	int y = 20;
	cout << x << " " << y << endl; // 10 20
	func(x, y);
	cout << x << " " << y << endl; // 20 10

	system("pause");

	return 0;
}

void func(int &a,int &b)
{
	int c = 0;
	c = a;
	a = b;
	b = c;
}

猜你喜欢

转载自blog.csdn.net/qq2942713658/article/details/81811990
今日推荐