How to initialize an std::string using ""?
- by Mohsin
I'm facing problems with initializing a std::string variable using "" (i.e. an empty string). It's causing strange behavior in code that was previously working. Is the following statement wrong?
std::string operationalReason = "";
When I use the following code everything works fine:
std::string operationalReason;
operationalReason.clear();
I believe that string literals are stored in a separate memory location that is compiler-dependent. Could the problem I'm seeing actually be indicating a corruption of that storage? If so, it would get hidden by my usage of the clear() function.
Thanks.