벡터 요소를 가리키는 반복자를 지니고 있으며 벡터의 다음 요소와 비교하고 싶습니다. 여기C++ 벡터 <T> :: iterator 연산자 +
는 foo는 어디 내가
Class Point{
public:
float x,y;
}
//Somewhere in my code I do this
vector<Point> points = line.getPoints();
foo (points.begin(),points.end());
이 무엇 :
void foo (Vector<Point>::iterator begin,Vector<Point>::iterator end)
{
std::Vector<Point>::iterator current = begin;
for(;current!=end-1;++current)
{
std::Vector<Point>::iterator next = current + 1;
//Compare between current and next.
}
}
내가이 일 것이라고 생각하지만, current + 1
나에게 벡터의 다음 요소를 제공하지 않습니다.
비록 운영자 +가가는 길 이었지만 그렇게 느껴지지 않았습니다. 이것에 대한 해결 방법이 있습니까?
감사
'next'가 현재 이후의 요소를 참조하지 않는다고 생각하는 이유에 대해 자세히 설명해 주시겠습니까? –
"하지만 현재 + 1이 나에게 벡터의 다음 요소를 제공하지 않는다"는 것을 명확히 할 수 있습니까? ? – Naveen
이것은 완벽하게 괜찮아 보인다. –