I saw this code
a<?=b; // (a and b are int)
from the solution of Google Code Jam.
but my VS shows an error on '?'
I only know the following:
a>b?a=0:b=0;
Thanks.
I saw this code
a<?=b; // (a and b are int)
from the solution of Google Code Jam.
but my VS shows an error on '?'
I only know the following:
a>b?a=0:b=0;
Thanks.
Old operator; it's a (since removed) gcc extension for 'minimum'. That is:
a <?= b;
is the same as:
a = a < b ? a : b;
A nonstandard GCC extension to C++ allows <?
as an operator which is equivalent to min
. I haven't seen <?=
before, but presumably it's an in-place version; that is, a <?= b
is equivalent to a = min(a,b)
.
Note that the GCC developers woke up the next morning and realized what a bad idea that was. The operator is now deprecated.
If a happens to be larger than b, it would set a to b.
Essentially the same as:
a = a < b ? a : b;
Example:
int a = 5;
int b = 2;
a<?=b; //a is now 2!
I wouldn't advocate actually using such a solution though, it is horrible.
As others have said, it's part of a nonstandard GCC extension, but please don't use it.