Why is the code compiling even though I am passing variables to swap function, instead of pointers or addresses?
#include <iostream>
using namespace std;
void swap(int *a, int *b)
{
int *tmp;
tmp = a;
a = b;
b = tmp;
}
int main ()
{
int x = 1;
int y = 2;
swap (x,y); /*Note: calling swap function using actual variables, not using addresses*/
cout << " x = " << x << " y = " << y << endl;
}