Possible Duplicate:
Order of evaluation of arguments using std::cout
I have known it now!This is responsible for 'cout' The all code:
#include <iostream>
using namespace std;
int main()
{
int i = 3;
cout <<-i++<<endl<<i<<endl<<-(i++)<<endl<<i<<endl;
return 0;
}
I use VC++6.0 to compile,output is : -4 4 -3 3
But I use g++ to compile,output is : -4 5 -3 5
Why? I think they should be the same : -4 4 -4 4
PS:I try it:
int main()
{
int i = 3;
cout <<-i++<<endl;
return 0;
}
And
int main()
{
int i = 3;
cout <<-(i++)<<endl;
return 0;
}
I compile they one by one,the result is the same:-3 3 Thinks to all answers,I maybe have a mistake of testing -i++ and -(i++) somehow