Hi,
I ran into a problem I currently don’t really understand, but it’s easy to prevent it from happening.
I would still like to understand why it doesn’t work.
This is my code.
Both are declared public in the header.
ChengelChargeCooldown, the int works just fine.
As soon as i try the same with a float, like ChengelChargeMinRange i get the compiling error c4706 assignment within conditional expression.
I would really like to understand why this doesn’t work.
Cheers,
Proby
What’s the return type of RequestStatByKey
?
Also operator==
has higher precedence than operator=
(see C++ Operator Precedence - cppreference.com). If you want the assignment to happen first and then compared against -1
then you need to add additional parentheses. Alternatively just do the assignment before the condition. Would probably also make it easier to read than having too much stuff happening in the same line. The int
case probably works due to some implicit conversion. Compiler Explorer
RequestStatByKey is a void function. So there is no return type.
Thank you for the explanation. I already used your solution of doing the assignment before the condition.