M
MSDousti
Hi,
I'm confused with C++'s unary increment operator(++).
Consider the following code:
//////////////////////////////////////////////////////////////////////
#include <iostream>
using namespace std;
int main()
{
int a=2;
a= (a==2 ? a+=100:0) + (a>3 ? a+=200:1000) + a++;
cout << a << endl;
return 0;
}
//////////////////////////////////////////////////////////////////////
I have run this code both on linux (using g++) and windows (VS.NET).
Surprisingly, the resaults were incompatible!
g++ answers: 507
VS answers: 707
Can anyone help?
I'm confused with C++'s unary increment operator(++).
Consider the following code:
//////////////////////////////////////////////////////////////////////
#include <iostream>
using namespace std;
int main()
{
int a=2;
a= (a==2 ? a+=100:0) + (a>3 ? a+=200:1000) + a++;
cout << a << endl;
return 0;
}
//////////////////////////////////////////////////////////////////////
I have run this code both on linux (using g++) and windows (VS.NET).
Surprisingly, the resaults were incompatible!
g++ answers: 507
VS answers: 707
Can anyone help?