Hi Frank,
I am not sure what exactly your code looks like. I assume that you have the
code snippets like the following:
//---a.cpp
int CA::GetVariableLen(){
static const CString TEST = _T("aaaa");
return TEST.GetAllocLength();
}
//--b.cpp
int CB::GetVariableLen(){
static const CString TEST = _T("bbb");
CA aa;
int nLenA = aa.GetVariableLen();
int nLenB = TEST.GetAllocLength();
return nLenA>nLenB ? nLenA : nLenB;
}
At upper level, you execute the following code:
CB bb;
int n = bb.GetVariableLen();
......
and you would like to know the TEST constant values in both
CA::GetVariableLen and CB::GetVariableLen() after you call
bb.GetVariableLen() outside or aa.GetVariableLen() within
CB::GetVariableLen().
In this case, I recommend that you use TRACE macro to record their runtime
values so that you can see the list of them in the Output window. For
example:
int CA::GetVariableLen(){
static const CString TEST = _T("aaaa");
TRACE(_T("TEST in CA::GetVariableLen():") + TEST + _T("\n"));
return TEST.GetAllocLength();
}
int CB::GetVariableLen(){
static const CString TEST = _T("bbb");
TRACE(_T("TEST in CB::GetVariableLen():") + TEST + _T("\n"));
CA aa;
int nLenA = aa.GetVariableLen();
int nLenB = TEST.GetAllocLength();
return nLenA>nLenB ? nLenA : nLenB;
}
Then in the Output window, you can find the following output when you debug
your application in Visual Studio:
TEST in CB::GetVariableLen():bbb
TEST in CA::GetVariableLen():aaaa
Hope this helps. If you have any other questions or concerns, please feel
free to let me know.
Best regards,
Charles Wang
Microsoft Online Community Support
=========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: ***@microsoft.com.
=========================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
=========================================================