I have written a code in c++ to check the variable increment (Screenshot added). In line 13 when I use "++x" in printing function to print the value of x and y. The value I'm getting is not equal but the memory address is same. In line 17 I've incremented y as ++y and I got my expected equal ans (Screenshot added) My Code Screenshot.
What is the reason for not getting the unexpected ans in line 13?
My Code: https://gist.github.com/mefahimrahman/7fb0f45ae1f45caeb97d5aaeb39c4833
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x = 7, &y = x;
cout << "Whithout Increment: ";
cout << &x << " " << &y << endl;
cout << x << " " << y << endl;
--x;
cout << "After x Increment: ";
cout << &x << " " << &y << endl;
cout << ++x << " " << y << endl;
y++; cout << "After y Increment: ";
cout << &x << " " << &y << endl;
cout << x << " " << ++y << endl;
}