title: what is wrong with subscript of string here in C++
body: <p>This code should print "something here", but it actually print wrong</p>
  
  <pre><code>void test(){
      string str = "";
      int count = 0;
      if (count &gt; str.length() - 1){
          cout &lt;&lt; "something here" &lt;&lt; endl;
          return;
      }
      cout &lt;&lt; "wrong" &lt;&lt; endl;
  }
  </code></pre>
  
  <p>But, if I change a little as below, it will print "something here"</p>
  
  <pre><code>void test_2(){
      string str = "";
      int count = 0;
      int last_index = str.length() - 1;
      if (count &gt; last_index){      // change to last_index
          cout &lt;&lt; "something here" &lt;&lt; endl;
          return;
      }
      cout &lt;&lt; "wrong" &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Anyone can help me?</p>