参数使用

#include<iostream>
using namespace std;
void input(int &a)                   
{
	a++;
	cout<<"被调用后"<<a<<endl;
}
int main()
{
	int j;
	j=1;
	input(j);
	cout<<"其值本身变化"<<j<<endl;
	system("pause");
	return 0;
}
//在上面的例子中a只是j的别名,调用函数后对a的操作会影响到j;
//而当调用函数变为input(int a)后,是把j的值赋给a,调用函数后对a的操作不会影响到j;

原文地址:https://www.cnblogs.com/zztong/p/6695268.html