itsmydamnation
Veteran
i can't see a better forum then this,
I have just started learning C++ my first real language ( i know perl pretty well)
was just trying stuff, getting farmilar with the way things can be expressed.
came across this.
now this equals 24, by my logic and order of operations this should be 21 ( 6 + 7+ 8) but its doing 8+8+8. i can speculate why its doing it and how, but can someone explain exactly why?
cheers
I have just started learning C++ my first real language ( i know perl pretty well)
was just trying stuff, getting farmilar with the way things can be expressed.
came across this.
Code:
int main()
{
void increment();
}
void increment()
{
using namespace std;
int y = 5,x;
x = (++y)+ (++y) + (++y);
cout<<x<<endl;
}
now this equals 24, by my logic and order of operations this should be 21 ( 6 + 7+ 8) but its doing 8+8+8. i can speculate why its doing it and how, but can someone explain exactly why?
cheers