Issue deleting Node w/ one child

Hello all. I'm having issues with my code for deleting a Node from a BST with one child. I can't see why it is crashing my program. Here's a sample of how I am deleting the node. Essentially I have a find function that returns true and sends to delete once the current node has an m_left or m_right that matches the word we are looking to remove. Here's a small snippet that is giving me trouble, and I can't see why

1
2
3
4
5
6
7
8
	if (cur_root->m_left->m_word == word){
		if (cur_root->m_left->m_left != NULL && cur_root->m_left->m_right == NULL){
			Node *temp = cur_root->m_left->m_left;
			delete cur_root->m_left;
			cur_root->m_left = temp;
			delete temp;
			return;
		}
Last edited on
Could it have something to do with my Node destructor? I'm really at a loss... here's my Node destructor

1
2
3
4
		~Node(){
			delete m_left;
			delete m_right;
		}


I've gone through the logic on paper like 10 times and really don't see why it's crashing
Topic archived. No new replies allowed.