#include <iostream.h>
int main()
{
int x=99;
if(x++<100)
{
cout<<"it is false";
}
else
{
cout<<"it is true";
}
return 0;
}
i wonder why if i try to run this it gives me false even when i change the < to> and if i try to cout at the end the x++ it gives me 99 and when i channge and incrimate it at the end it gives me 100 also if i change the false to true it starts displaying true
I wish the C++ tutorial on this site was more clear about it returning the old value via making a copy before increment; it currently makes it sound like post-increment is multi-threaded and doesn't involve making a copy:
in case that it is used as a suffix (a++) the value stored in a is increased after being evaluated and therefore the value stored before the increase operation is evaluated in the outer expression.
It could be poor wording, as "stored" here is used in a way that could mean the correct thing, but it is unclear.