Re: ATL CString losing count
Can you post a minimal compilable example that reproduces the problem? The
code above, by itself, is perfectly legal. There is no reason why it
should produce any problems. I fear that you have only found a workaround
for the real problem, which is prone to come back when you least expect
it. I would continue to search for the real problem.
Of course I can't reproduce it now, I thought in more detail it resolved
down to the following, but this compiles and runs OK. I'll dig out the old
faulty code over the weekend and have another try. Problem is the char comes
from another class not written by me and I'm not sure how much I can reduce
it.
class TestChar
{public:
char xc;
TestChar()
{xc='X';}
};
class TestCString
{public:
TestChar *pTestChar;
CString TestString;
TestCString()
{pTestChar = new TestChar();}
~TestCString()
{delete pTestChar;}
void SetStr()
{TestString = CString(pTestChar->xc);}
};
void CStringProblem()
{TestCString *tc = new TestCString();
tc->SetStr();
delete tc;
}