Exercise information
Exercise 3.9
What does the following program do? Is it valid? If not, why not?
string s;
cout << s[0] << endl;
Question or Bug
Maybe should mention string s is empty string.
Answer was
Try to get the first element of the string. It is invalid, cause this is undefined behavior.
Answer modified
Try to get the first element of the empty string s (default initialization). It is invalid, cause this is undefined behavior.