operator char* in STL string class
c++, stl
Solution
Following is the quote from Josuttis STL book:
However, there is no automatic type conversion from a string object to a C-string. This is for safety reasons to prevent unintended type conversions that result in strange behavior (type char* often has strange behavior) and ambiguities (for example, in an expression that combines a string and a C-string it would be possible to convert string into char* and vice versa). Instead, there are several ways to create or write/copy in a C-string, In particular, c_str() is provided to generate the value of a string as a C-string (as a character array that has '\0' as its last character).
Problem
Why doesn't the STL string class have an overloaded char* operator built-in? Is there any specific reason for them to avoid it? If there was one, then using the string class with C functions would become much more convenient. I would like to know your views.