Possible Duplicate:
Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc…)
Why this code is generating 8 as a result ?
#include <iostream>
using namespace std ;
void myFunction(int i)
{
i = i + 2 + ++i;
cout<<i<<endl;
}
void main ()
{
int i = 2;
myFunction(i);
cin>> i;
}
I think the result should be 7 not 8...I am using Visual Studio 2008