更新时间:2023-11-12 20:07:28
错误是因为该语言不允许.
The error is because the language does not permit it.
根据C ++标准, [cpp.cond]/1
:
As per the C++ standard, [cpp.cond]/1
:
控制条件包含的表达式应为整数常量表达式.
The expression that controls conditional inclusion shall be an integral constant expression.
不是将 ZOOM_FACTOR
定义为浮点值 1.5
,而是为什么不将其定义为该值的倍数.例如,与常数 2
相乘,然后进行比较.
Instead of defining ZOOM_FACTOR
as floating point value 1.5
, why not define it as a multiple of such value. For example, multiply with a constant such as 2
and then make your comparisons.