#include <iostream>
using namespace std;
int main()
{
int var1 = 5;
int var2 = 6;
if ((var2 = 1) == var1)
cout << var2;
else
cout << (var2 + 1);
}
I want to understand how does the var2=1 assignment work. I mean what happens when the value 1 is assigned to var2 and how (and why ) can we compare an assignment operation(var2=1) with a variable. Basically I want to understand what going on behind the scenes . If anybody can help ?