在什么情况下会在这种情况下执行死刑? [英] Under what circumstances will the body under the condition be executed?
问题描述
很久以前,在接受采访时,我偶然发现了这个问题:
Long time ago, while being interviewed, I stumbled across this question:
假设在某处,我们已经获得了这一行代码。您能否提供至少三种情况来导致在条件下的尸体被处决?
Suppose, somewhere, we have gotten this line of code. Could you provide at least three cases which would cause the body under the condition to be executed?
if (a == 3 && a == 4) { /* ... */ }
我的答案是:
-
'a'很可能是带有重载相等运算符的自定义类。
It is quite possible that 'a' might be a custom class with overloaded equality operator.
'a'可以在 #define a b ++
的某个地方定义(或重新定义),如果b等于3,则它将被评估为 true
。
'a' might be defined (or re-defined) somewhere as #define a b++
, and if b equals 3, then it will be evaluated as true
.
必须存在某种多线程问题,例如,不同的线程访问相同的变量。
There must be some kind of multithreading problem, such as, different threads access the same variable.
转到标签
我没有要求澄清,也没有被告知我的回答是否正确。您将如何进行?有什么有趣的答案吗?
I did not ask for the clarification, and also was not told whether my answers were right. How would you proceed? Are there any interesting answers?
推荐答案
那不是循环。
显示的循环已执行。
这篇关于在什么情况下会在这种情况下执行死刑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!