我在CB的FormCreate中用了new函数,那我在哪用delete啊?
CWLogFile::CWLogFile()
{
m_strPath = new char[200];
m_strFileName = new char[100];
memset(m_strPath, 0, sizeof(m_strPath));
memset(m_strFileName, 0, sizeof(m_strFileName));
//默认当前目录
char szExePath[MAX_PATH];
GetModuleFileName(NULL, szExePath, MAX_PATH);
*(strrchr(szExePath, '\\')) = '\0';
strcpy(m_strPath, szExePath);
sprintf(m_strFileName, "%s.txt", CTime::GetCurrentTime().Format("%Y-%m-%d"));
}
CWriteLogFile::~CWriteLogFile()
{
delete [] m_strPath;
delete [] m_strFileName;
}
上面是vc里的代码,我改在cb中运行。我把构造函数里的东西都放在FormCreate里了,现在我不知道应该把原来的析构函数中的delete放哪啊?
[解决办法]
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action){ //your code }