title: How to use something like a continue statement in nested for loops?
body: <p>I have a class of objects and need to compare one property of each object to the same property of all other objects. If they match, the code needs to do something. This results in two 'for loops' looping through the objects to get that property, and in the second 'for loop', there is a third 'for loop' going through the elements of the property (which is a vector) to compare them. If they match, I need the outer most 'for loop' to abort the current iteration and go on to the next one (I only want the first match with another object to be considered).</p>
  
  <p>I have looked into 'goto' statements and into creating a do{}while() structure, but have not been able to implement them in a way to get the desired result. What I need is something like a 'continue' statement for the outer most loop based on what happens in the conditional statement in the inner most loop. </p>
  
  <p>Which would be a good method to achieve this, and how would it have to be implemented?</p>
  
  <p>Edit: Next to the answer I accepted, I would also recommend Martin Bonner's answer, which also works perfectly fine and doesn't rely on goto.</p>
  
  <pre><code>for (int i = 0; i &lt; max; i++){
  Object &amp; object1 = system.getAgent(i);
  VectorOfStrings object_property1 = object1.getProperty();
  
      for (int j = i + 1; j &lt; max; j++){
      Object &amp; object2 = system.getObject(j);
      VectorOfStrings object_property2 = object2.getProperty();
  
          for (unsigned int k = 0; k &lt; object_property1.size(); k++){
  
              if (object_property1[k] == object_property2[k]){
  
              //do something
  
              break; //this aborts the inner most loop
              //Additionally, I need the outer most loop to move on one iteration
              }
          }
      }
  }
  </code></pre>
  
  <p>So if the conditional statement in the 'k' loop is met, I want the 'i' loop to abort the current iteration and move on to the next one.</p>
  
  <p>Also, since I'm new, the code might be inelegant, but please focus on this specific problem in your answers! Unless a general restructuring of the code might be the solution to the problem of course :)</p>