#include<iostream> #include<string> using std::string; using std::cout; using std::endl; int main() { string s; cout << s.size() << endl; cout << s[0] << endl; //output empty line return 0; }
How s is an empty string, why can it have an element s [0] ? In my opinion, it should get a runtime error. Is this an agreement or something else?
source share