在Dlg类中定义CTime型全局变量Bebug时系统报First-chance解决方法
在Dlg类中定义CTime型全局变量Bebug时系统报First-chance
我定义一个CTime型变量
class CTest1Dlg : public CDialog
{
// Construction
public:
//
CTime t1;
在CTest1Dlg::OnInitDialog
有如下代码:
t1.GetCurrentTime();
CTimeSpan ts(86400L);
t1=t1-ts;
Build没有问题,但一旦Debug运行,系统就会报
Loaded 'C:\WINDOWS\system32\mfc42loc.dll', no matching symbolic information found.
First-chance exception in Test1.exe: 0xC0000005: Access Violation.
如果把t1变为私有变量,Debug就能正常运行。
我需要如何解决该问题?
------解决方案--------------------
你应该用 t1 = CTime::GetCurrentTime();
GetCurrentTime()函数是静态函数.
我定义一个CTime型变量
class CTest1Dlg : public CDialog
{
// Construction
public:
//
CTime t1;
在CTest1Dlg::OnInitDialog
有如下代码:
t1.GetCurrentTime();
CTimeSpan ts(86400L);
t1=t1-ts;
Build没有问题,但一旦Debug运行,系统就会报
Loaded 'C:\WINDOWS\system32\mfc42loc.dll', no matching symbolic information found.
First-chance exception in Test1.exe: 0xC0000005: Access Violation.
如果把t1变为私有变量,Debug就能正常运行。
我需要如何解决该问题?
------解决方案--------------------
你应该用 t1 = CTime::GetCurrentTime();
GetCurrentTime()函数是静态函数.