【发布时间】:2018-09-28 14:54:21
【问题描述】:
所以我有 ListOne 和 ListTwo,它们都包含 {9, 11, 12}。但是,在下面的代码中,保存列表末尾值的迭代器保存的值甚至不在列表中。 编辑:所以我发现 listOne.end() 正在返回列表的大小。为什么?
auto firstIteratorBegin = listOne.begin();
auto secondIteratorBegin = listTwo.begin();
auto firstIteratorEnd = listOne.end();
auto secondIteratorEnd = listTwo.end();
//Check if two lists are in the same range.
if(*firstIteratorEnd < *secondIteratorBegin || *secondIteratorEnd < *firstIteratorBegin)
{
return false;
}
【问题讨论】:
-
你的列表变量是什么类型的?