I'm so new to c++, and i've just started doing pointers so when i'm using call by reference using pointers one thing i cant understand when i'm passing the addresses of the values , it works as it should be
void swap(int* a, int* b) {
    int temp = *a;
   *a = *b;
   *b = temp;
}
int main(){
    int x=5 , y=10;
    swap(&x , &y);
    std::cout<<"The value of x is "<<x<<std::endl;
    std::cout<<"The value of y is "<<y<<std::endl;
}
but when i'm passing the values not the addresses it still works how?
int main(){
    int x=5 , y=10;
    swap(x , y);
    std::cout<<"The value of x is "<<x<<std::endl;
    std::cout<<"The value of y is "<<y<<std::endl;
}
 
    