Skip 1st Iteration of Range-Based For Loops

前端 未结 2 1666
深忆病人
深忆病人 2020-12-16 01:16
for (int p : colourPos[i+1])

How do I skip the first iteration of my colourPos vector?

Can I use .begin and

2条回答
  •  星月不相逢
    2020-12-16 01:51

    Do this:

    bool first = true;
    
    for (int p : colourPos)
    {
        if (first)
        { first = false; continue; }
    
        // ...
    }
    

提交回复
热议问题