为什么最好使用'!='比'<'在向量循环中? (C ++) [英] Why is it better to use '!=" than '<' in a vector loop? (C++)

查看:59
本文介绍了为什么最好使用'!='比'<'在向量循环中? (C ++)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么最好使用'!=而不是'<'在向量循环中吗?我只是看不到区别.

Why is it better to use '!=" than '<' in a vector loop? I just can't see the difference.

推荐答案

由于您使用的是迭代器,因此如果您选择切换到其他容器类型(例如,设置,列出,无序设置等.其中<没有任何意义.

Because you're using iterators, and it'll make the loop look exactly the same as other containers, should you choose to switch to other container types, such as set, list, unordered_set, etc. where < has no meaning.

这篇关于为什么最好使用'!='比'&lt;'在向量循环中? (C ++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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