任何人都可以解释这个程序中定义函数的工作背后的逻辑。即使在评论整个函数逻辑之后,这也会在这种情况下给出正确的输出。
#include <iostream>
using namespace std;
void swap(int *a, int *b)
{ /*
int temp=0;
temp= *a;
*a= *b;
*b=temp;
*/
}
int main()
{
int x, y;
cout << "This program is the demo of function call by pointer \n\n";
cout << "Enter the value of x & y \n";
cout << "x: ";
cin >> x;
cout << "y: ";
cin >> y;
cout << "Value befor swap " << endl;
cout << "x= " << x << …Run Code Online (Sandbox Code Playgroud)