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.
Could the problem I'm seeing actually be indicating a corruption of that storage?<-- No. If it were, you would have numerous other problems such as massive system instability. There's no reason for the code you're giving to not work.operationalReason.size()is non-0 immediately after doingstd::string operationalReason = "";, that's would prove that something is horribly wrong. If it is 0 then probably the string has been created OK.std::string operationalReason;but I'm still seeing operationalReason as a string with no printable characters and length 16. How weird is that?