求解析下
#include<iostream>using namespace std;
void get_numbers(int& input1,int& input2);
void swap_values(int& variable1,int& variable2);
void show_results(int out1,int out2);
int main()
{
int first_num,second_num;
get_numbers(first_num,second_num);
//cout<<first_num;
swap_values(second_num,first_num);
//cout<<first_num;
show_results(first_num,second_num);
return 0;
}
void get_numbers(int& input1,int& input2)
{
cout<<"Enter your two numbers:\n";
cin>>input1
>>input2;
cout<<endl;
}
void swap_values(int& variable1,int& variable2)
{
int tem;
tem=variable1;
variable1=variable2;
variable2=tem;
}
void show_results(int output1,int output2)
{
cout << "firstnum is :"<<output1<<endl;
cout <<"secondnum is:"<<output2<<endl;
}
当在把void swap_values(int& variable1,int& variable2)改为传值调用的时候,怎么交换功能就不能实现了?
本人新手,谢谢了!