I was just wondering, can an object (from a class) delete itself? The code below seems to compile fine, but I wanted to be sure. I do not access any of the member variables after the deletion (the NextNode is stored in a temporary variable), but I'm still doing operations in the objects method (member funtion).
Is this ok to do?
PreviousNextNode is a pointer to the previous node's NextNode pointer (!).Code://+----------------------------------------------------------------------------- //| Deletes a node from the list //+----------------------------------------------------------------------------- VOID GROUP::DeleteNode(GROUP** PreviousNextNode) { //Data GROUP* TempNode; //Stop if NULL is passed if(PreviousNextNode == NULL) return; //Delete the current node TempNode = NextNode; SafeDelete(*PreviousNextNode); (*PreviousNextNode) = NextNode; }



LinkBack URL
About LinkBacks



