假设我使用嵌套的 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/