是这些(bCondition == NULL)和(NULL == bCondition)之间的区别? [英] What is the difference between these (bCondition == NULL) and (NULL==bCondition)?

查看:245
本文介绍了是这些(bCondition == NULL)和(NULL == bCondition)之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在探索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.

感谢。

推荐答案

使用 NULL的==条件在错字的情况下,提供了更多有用的行为,当赋值运算符 = 不小心使用,而随后比较运算符 ==

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编译器给出了前一种情况的警告,有没有这样的警告在许多语言。

C-compiler gives a warning in the former case, there are no such warnings in many languages.

这篇关于是这些(bCondition == NULL)和(NULL == bCondition)之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆