【发布时间】:2015-06-18 15:28:54
【问题描述】:
以下两种记法的优缺点是什么?
if (a == 0) ...
和
if (0 == a) ...
第一个更具可读性。第二个呢?
【问题讨论】:
-
第二个也称为尤达条件,请参阅What is the difference between if (NULL == pointer) vs if (pointer == NULL)?,正如我在我的回答中指出的那样,对于现代编译器,这应该不再需要了。
标签: c++ coding-style standards notation