問題1:如何在不破壞回報的情況下從內存中刪除res?我是否刪除函數範圍內的記憶?
Class1 *GetType(Class1 type)
{
Class1 *res = nullptr;
switch (type)
{
case SCRIPTS_SPELL:
{
res = &sSpellScripts;
break;
}
case SCRIPTS_EVENT:
{
res = &sEventScripts;
break;
}
case SCRIPTS_POINT:
{
res = &sWaypointScripts;
break;
}
default:
{
break;
}
}
return res;
}
問題2:我刪除唱首歌並從內存中點擊函數內部或沒有?
bool Class2::IsFitToRequirements(Unit const *clicker, Unit const *click) const
問題3:我是否刪除有指針的記憶?例如:
QueryResult result = Database.Query(some query);
if (!result)
{
delete &result; // Should I or not?
return;
}
................什麼?!?! –