c++ - C++ 中的正确形式

标签 c++ defensive-programming

<分区>

Possible Duplicate:
What is the difference between these (bCondition == NULL) and (NULL==bCondition)?

来自 this question它说“比较左侧的常量对象”比其他方式“更好”。这是为什么?

最佳答案

任何体面的编译器都会警告您有关条件表达式中的赋值,因此如今这种形式不是很相关。

On another point "use unsigned for variables that are >= 0 // nice trick " I heard that using unsigned can be confusing and shouldn't use unless there's a reason. Does anyone agree or refute this?

当值应该是 unsigned 时使用 unsigned

关于c++ - C++ 中的正确形式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12205028/

相关文章:

security - web应用攻击,必须有防御方法

defensive-programming - 这是防御性编程吗?

c++ - 将指向前向声明类型的指针插入 typedef vector 时出现编译器错误

c++ - 在 C++ 中隐藏敏感字符串的技术

java - 围绕 superfirst 工作

error-handling - 如何隔离网页中的各个部分,以使一个部分不会影响其他部分

c# - C# 中的 C++ 结构

c++ - 如何使用 Boost Asio 减少编译时间

c++ - 在没有运行时的情况下构建 Windows C++ 库?

c++ - 试图掌握动态层次类关系的装饰器设计