Yes, this will give a reference to a null character, as specified in the C ++ 11 standard:
Requires: pos <= size() .
Returns: *(begin() + pos) if pos < size() , otherwise a reference to an object of type T with value charT() ; reference value should not be changed.
where charT() is a value-based character that will have a null value. T is supposedly a typo for charT . The C ++ 14 project (and presumably the final standard) says the same thing as a typo fixed.
If you have a book that says otherwise, burn it or sell it to your enemies.
source share