【发布时间】:2013-08-29 22:47:03
【问题描述】:
假设我有这样的代码:
if(condition1 || condition2 || condition 3 || condition4)
{
// this inner part will be executed if one of the conditions is true.
// Now I want to know by which condition this part is executed.
}
【问题讨论】:
-
除了打印
cout << "condition1=" << coundition1 << " condition2=" << condition2 ...? -
@captain:想多解释一下吗?
-
@captain 是什么让你觉得他的
if可以改写为switch。如果他的condition1等实际上是变量,那肯定不行,如果是任意表达式,那也不行。 -
在执行内部时。编译器知道哪个条件为真。我想知道执行内部的条件是正确的。
-
@mahesh 详细说明你的问题,也许你需要重新设计你的 if 语句
标签: c++ objective-c c if-statement