gpt4 book ai didi

C++ 风格指南 : why to have non-lvalues on the left side?

转载 作者:可可西里 更新时间:2023-11-01 17:16:43 30 4
gpt4 key购买 nike

合一C++ coding style guide ,我发现了一个特别的建议(第 41 页,建议编号 53):

Always have non-lvalues on the left side (0 == i instead of i == 0).

我不明白这有什么用?要坚持这种做法吗?

我不是,我也不知道为什么他是个好习惯。我能想到的唯一优点是,这将避免将无意分配误认为是比较( if (foo = 0){}if (foo == 0){} )

对于我为什么要使用它,您有任何其他想法吗?

最佳答案

是的,你猜对了。这是好的,老<强>Yoda condition !!!

enter image description here

关于C++ 风格指南 : why to have non-lvalues on the left side?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10076689/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com