What does this C ++ line of code mean "sol <? = F ((1 << n) -1, i, 0) + abs (P [i]) * price;"
Can someone help me understand the following line of code:
sol< ?=f((1<< n)-1,i,0)+abs(P[i])*price; I am learning an algorithm written using C ++ and has the following < ?= Operator. My problem is understanding the < ?= Operator. Also, when I compile this code using the g ++ compiler, it gives an error message for the line above the line of code code
The following is the error message.
Hello.cpp: In the function 'int main ():
Hello.cpp: 115: error: 'memset was not declared in this area
Hello.cpp: 142: error: expected primary expression before '? Marker
Hello.cpp: 142: error: expected primary expression before '= token
Hello.cpp: 142: error: expected ': before'; Marker
Hello.cpp: 142: error: expected primary expression before '; Marker
Maybe < ?= Is not a single statement, but I canโt understand what exactly this line of code does.
Thank you for taking the time to read this post.
This is a GNU extension. This is basically a lower statement.
int a = 3; a <?= 2; cout << a << endl; // prints 2, because 2 < 3 a <?= 10; cout << a << endl; // prints 2 as well, because 10 > 2 More details here .
Be clear to those who read this and cannot follow; <?= and >?= are destination versions <? and >? , which are legacy GCC extensions that served the purpose of (x>y)?x:y or (x<y)?x:y respectively.
Therefore, x <?= y; will x = x <? y; x = x <? y; which is x = (x<y) ? x : y; x = (x<y) ? x : y;
Most compiler providers introduce language extensions, and many of them are turning into future language standards. Typically, these extensions are simply very easy to add or to facilitate writing standard libraries.
It could be almost a line of PHP code: all that is needed is to remove the space that will be created at the end.
<?= foo(); ?> equivalently
<?php echo foo(); ?> Take a look at grammar C here
Single use ? - in the ternary operator:
conditional_expression : logical_or_expression | logical_or_expression '?' expression ':' conditional_expression ; If for ? followed by an expression. This does not happen in your case. So your code is not valid .
This line is not a line of code. That is why it does not compile. It makes no sense to ask what he is doing.