View Full Version : C/C++ prioroty question
Hrach_Techie
Aug 11, 2004, 10:01
Am confused..
int m[2] = { 1, 5 };
cout << ++*m; //this gives 2
my question is, why is the dereference operator evaluated before ++ inspite of the fact that ++ has a higher precedence than *? :yikes:
ANy pointers there?
Speedy Gonzales
Aug 11, 2004, 10:25
Операторы ++ и * имеют одинаковый приоритет и порядок выполнения справа налево. Скобки тебе не помогут?
ArsenD
Aug 11, 2004, 10:47
Everything seems to be fine... I don't see any problem here.
To be simple... in case of prefix unary operators, the operators are executed in the right-to-left order...
Agregat
Aug 11, 2004, 11:03
operator ++(void) has to be applied to something. Something is dereferenced m.
Hans Andersen
Aug 11, 2004, 12:49
just curious, what were you expecting?
Speedy Gonzales
Aug 11, 2004, 13:15
guess he expects 5
Hans Andersen
Aug 11, 2004, 13:39
but how can one ++arrays?
Agregat
Aug 11, 2004, 19:09
никак на самом деле. :)
[removed by administrator: you have one warning, read forum rules (http://forum.armkb.com/rules.html) and behave correspondingly]
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.