Hello,
I have a weird problem. I have a class implemented that looks something like the following:
class textBox {
public:
// default constructor
textBox() {
m_text = "";
}
textBox(string text) {
m_text = text;
}
string getText() { return m_text; }
private:
string m_text;
};
Now, when I use getText() in Debug mode (compiling using VS2008), it always returns the correct string that was placed into m_text via the constructor. However, when I use getText() in Release mode, the first time it returns the correct string, but from that point on, some (starting at the beginning) or all of the data in the string becomes corrupt or missing. I'm pretty sure that this is a problem in how memory is managed in Debug vs Release building. How can I make sure that the memory won't get overwritten with garbage in Release mode without dynamically allocating the string?
Thanks!