I don't want to use smart pointers.
Her'es my code.
CCOLFile *pCOLFile = CCOLManager::getInstance()->parseFile(strCOLPath); // returns instance of CCOLFile
// ...
pCOLFile->unload(); // hoping to comment this out, and use destructor instead.
delete pCOLFile;
struct CCOLFile
{
std::string m_strFilePath;
std::vector<CCOLEntry*> m_vecEntries;
};
void CCOLFile::unload(void)
{
for (auto pCOLEntry : m_vecEntries)
{
delete pCOLEntry;
}
m_vecEntries.clear();
}
Is it safe in c++ to comment my call to CCOLFile::unload, and then move the code from the CCOLFile::unload method to the CCOLFile destructor?
Aucun commentaire:
Enregistrer un commentaire