Does This 'for' Loop in C++ Cause an Error?

  • Topic: C/C++ 
  • Thread starter ineedhelpnow
  • Start date
  • Tags Tags
    Loops
2 replies · 2K views · last reply
ineedhelpnow
Messages
649
Reaction score
0
does this result in an error?

for (i = 0; i < itemsLast.size(); ++i)
{
itemsList.at(i) = itemsList.at(i+1);
}
 
Counting begins at zero, so if you have an array with $n$ elements, the index value for the last element is therefore $n-1$. So, does the loop result in an error?