在浏览 msdn 站点时,他们使用的大多数条件检查位置 (NULL == bCondition).
While exploring msdn sites ,most of the condition checking places they are using (NULL == bCondition).
使用这些符号的目的是什么?
what is the purpose of using these notations?
请提供一些示例来解释这些.
Provide some sample to explain these please.
谢谢.
当赋值运算符 =
被意外使用而不是比较运算符 ==
:
The use of NULL == condition
provides more useful behaviour in the case of a typo, when an assignment operator =
is accidentally used rather then the comparison operator ==
:
if (bCondition = NULL) // typo here
{
// code never executes
}
if (NULL = bCondition) // error -> compiler complains
{
// ...
}
C-compiler 在前一种情况下会给出警告,很多语言都没有这样的警告.
C-compiler gives a warning in the former case, there are no such warnings in many languages.
这篇关于这些 (bCondition == NULL) 和 (NULL==bCondition) 之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!