Re: Unary +
- From: Stephen Sprunk <stephen@xxxxxxxxxx>
- Date: Wed, 04 Mar 2009 13:27:00 -0600
karthikbalaguru wrote:
On Mar 4, 11:26 pm, Eric Sosman <Eric.Sos...@xxxxxxx> wrote:karthikbalaguru wrote:Hi,
What is the use of the Unary + Operator ?
Thx in advans,
not much some ppl like it as a defense against
if (x = y) ...
they rite
if (+x = y) ...
instead, which the cplr will complain about . unless there
r Macros involved i think its slly ur wlcm
Cool !!
I was eager to know of its use becuase some
referred it as dummy operator.
So, it is applicable only in this scenario and not
in other places.
It can be applied in lots of places, but it's almost always pointless to do so. This is one specific exception, and not a particularly useful one either since, if you can remember to put the + in as a defense against mistyping ==, you can just as easily remember to get the == right. A better example would be in a list of constants where you wanted to make the sign of every constant, both positive and negative, explicit rather than only putting a sign on the negative ones, which might make it easier to read or help detect typos.
However, I suspect that it was included mainly for completeness and because there was nothing else one could reasonably do with a unary + that wouldn't confuse a lot of programmers.
S
--
Stephen Sprunk "Stupid people surround themselves with smart
CCIE #3723 people. Smart people surround themselves with
K5SSS smart people who disagree with them." --Isaac Jaffe
.
- Follow-Ups:
- Re: Unary +
- From: blargg
- Re: Unary +
- From: Peter Nilsson
- Re: Unary +
- References:
- Unary +
- From: karthikbalaguru
- Re: Unary +
- From: Eric Sosman
- Re: Unary +
- From: karthikbalaguru
- Unary +
- Prev by Date: Re: Unary +
- Next by Date: Re: Interview Questions
- Previous by thread: Re: Unary +
- Next by thread: Re: Unary +
- Index(es):
Relevant Pages
|