Why C++ empty string can be accessed at any position without error?
For example,
string str("");
str[1]
, str[2]
will just return empty.
Why doesn't the following statement throw error?
str[2] = 'a'
But, printing out str
still show empty string.
I am confused here and probably miss something.