我有以下法典:
float x = 0.43;
float y = 1.56;
size_t largerValueIndex = 1;
size_t smallerValueIndex = 0;
switch (x > y) {
case 1:
largerValueIndex = 0;
smallerValueIndex = 1;
break;
}
视力演播室发布警告“C4144: > :作为开关声明的关系表述”。
What I d like to know is why is the warning necessary? I was under the impression that most switch and if statements are comparisons between two values. Is this considered bad practice? And if so, why?
我的问题必须涉及作为开关表达方式所使用的价值,而不是那些情况。