gpt4 book ai didi

c++ - 同一集合上的两个不同迭代器是否相等

转载 作者:搜寻专家 更新时间:2023-10-31 00:00:27 24 4
gpt4 key购买 nike

假设我使用嵌套的 for 来比较同一列表中的对象:

for( list<Object>::iterator iter = list.begin() ; iter != list.end() ; ++iter )
{
for( list<Object>::iterator iter2 = list.begin() ; iter2 != list.end() ; ++iter2 )
{
if( iter == iter2 )
{
// does this mean iter is pointing to the same INDEX
// as iter2? Will this work as expected?
}
}
}

最佳答案

... to compare objects in the same list:

是的,这正是您所期望的,并且工作正常。

关于c++ - 同一集合上的两个不同迭代器是否相等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13125645/

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