binary tree c++
The program compiles, but when I run it it crashes when it tries to output what is wrong //-------------------------- Node.h class Node { public: Node* _RHand ; Node* _LHand; Node* _head; int data ; Node()=delete ; Node (int input_data); void insert_Node(int data , Node* Ihead = nullptr); void get_min(); }; //--------------------Node.cpp #include "node.h" #include <iostream> using std::cout; Node::Node(int input_data) { this->data = input_data ; this->_head = this ; this->_LHand = nullptr ; this->_RHand = nullptr ; } void Node::insert_Node(int data , Node* Ihead ){ if (Ihead == nullptr ) Ihead = this->_head ; if (Ihead->data >data){ if (Ihead->_LHand == nullptr){ Node* tem = new Node (data) ; Ihead ->_LHand = tem ; delete tem ; }else{ insert_Node(data, Ihead->_LHand); } }else { if (Ihead->_RHand == nullptr){ Node* tem = new Node (data) ; Ihead ->_RHand = tem ; delete tem ; }else { insert_Node(data, Ihead->_RHand); } } } void Node::get_min(){ Node* tem = _head; while (tem->_LHand !=nullptr) { cout<< tem->data ; tem =tem->_LHand ; } } //------------main #include "node.h" int main() { Node* start = new Node (32); start ->insert_Node(23); start ->insert_Node(15); start ->insert_Node(13); start ->insert_Node(3); start ->insert_Node(2); start->get_min(); } //---------------------output Binary crashed.