我有以下代码:
string s = "haha";
cout << s << endl; //haha
cout << s.length() << endl; //4
cout << (s[25] == 'h' ? "is h" : "is not h") << endl; //is not h
cout << s[0] << endl; // h
cout << s[25] << endl; // nothing...blank
Run Code Online (Sandbox Code Playgroud)
似乎指向任何索引,即使它超出范围也不会抛出任何错误......这是什么原因?
| 归档时间: |
|
| 查看次数: |
748 次 |
| 最近记录: |