I was trying to generate an error in swap code in C++. Interestingly, instead of an error, it successfully shows the opposite. My code look like this: 

```
#include<iostream>  
using namespace std; 

void swap(int *x, int *y)                                                        
{                                                                                
    int *tmp = x;                                                                
    x = y;                                                                       
    y = tmp;                                                                     
}

int main()                                                                       
{                                                                                
    int u = 10;                                                                  
    int v = 20;                                                                  
    int * p = &u;                                                                
    int * q = &v;                                                  
    swap(*p, *q);                                                                
    std::cout<<"u :-"<<u<<" v  :-"<<v<<endl;                                     
    return 0;                                                                    
} 

```

The value of `u` and `v` got swapped. In this, I am passing pointer value instead of reference but the value gets swapped, How? 

Exact code can be found at:
<https://ideone.com/kMJHL6>