title: No Out_Of_Bounds error even after trying to access illegal element in string in c++
body: <p>In the below code, I have initialised an empty string 'a' and now I am arbitrarily trying to print any value out of it. Please help me understand why it does not show any error and prints garbage value instead!</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  int main() {
      string a = "";
      for(int i=0;i&lt;10;i++)
          cout&lt;&lt;a[i];
       for(int i=0;i&lt;10;i++)
          cout&lt;&lt;(int)a[i];
      cout&lt;&lt;"|";
      cout&lt;&lt;"\n"&lt;&lt;a.size();
  }
  </code></pre>