On Oct 6, 2:01 pm, puzzlecracker <ironsel2...@gm ail.comwrote:
How can we implement operator ++ as postfix in prefix?
>
thanks
Not really sure what you are asking, but the ++ operator can be
applied in front of a variable or behind it. If in front, the value is
incremented before the value is "looked at". If after, the value isn't
incremented until after it is "looked at".
How can we implement operator ++ as postfix in prefix?
>
thanks
In C
int a=10;
printf("%d\n", ++a);
prints 11 and
int a=10;
printf("%d\n",a ++);
prints 10
(and on both cases, a is 11 after the code).
The first ++ is called prefix and the second postfix.
On C++ if you like to add ++ to your own classes, you have to implement
separate operators for postfix and prefix ++ operators. However, this
article : http://devhawk.net/2003/07/10/Operat...ding+In+C.aspx
claims that for C# you have to implement only one operator, the compiler
handles the difference.
Comment