Don't understand the output of the given code : <p>Just jumped into C++ and tried to run the following code:</p>

<pre><code>#include &lt;iostream&gt;

using namespace std;


class BST_Node{
    private:
        int val;
        BST_Node* left;
        BST_Node* right;
    public:
        void setVal(int);
        int getVal();
        void setLeft(BST_Node*);
        BST_Node* getLeft();
        void setRight(BST_Node*);
        BST_Node* getRight();
        BST_Node(int val){this-&gt;val=val;this-&gt;left=nullptr;this-&gt;right=nullptr;}
};

class BST{
    private:
        BST_Node* root;
    public:
        void setBSTRoot(BST_Node* node){root=node;}
        BST_Node* getBSTRoot(){return this-&gt;root;}
};

BST createBST(int*, int);

void placeNode(BST_Node*, int);
void BST_Node::setVal(int val){
    this-&gt;val = val;
    cout&lt;&lt;"11: "&lt;&lt; val &lt;&lt; endl;
}

int BST_Node::getVal(){
    return this-&gt;val;
}

void BST_Node::setLeft(BST_Node* left){
    this-&gt;left = left;
}

void BST_Node::setRight(BST_Node* right){
    this-&gt;right = right;
}

BST_Node* BST_Node::getLeft(){
    return this-&gt;left;
}

BST_Node* BST_Node::getRight(){
    return this-&gt;right;

}

void print_inorder(BST_Node root){
    cout&lt;&lt;"working"&lt;&lt;endl;
    if(root.getLeft()!=nullptr){
        print_inorder(*(root.getLeft()));
    }
    cout&lt;&lt;"*"&lt;&lt;root.getLeft()-&gt;getVal() &lt;&lt;"*" &lt;&lt; endl;
    cout&lt;&lt;"*"&lt;&lt;root.getVal() &lt;&lt;"*" &lt;&lt; endl;
    cout&lt;&lt;"*"&lt;&lt;root.getRight()-&gt;getVal() &lt;&lt;"*" &lt;&lt; endl;
}


BST createBST(int* arr, int arr_size){
    BST obj_bst;
    BST_Node* root;
    cout&lt;&lt;"0 "&lt;&lt;endl;
    root = obj_bst.getBSTRoot();
    cout&lt;&lt;"1: "&lt;&lt; (*arr) &lt;&lt; endl;
    //cout&lt;&lt;"create BST " &lt;&lt; root-&gt;getVal() &lt;&lt;endl;
    root-&gt;setVal(*arr);
    cout&lt;&lt;"2 "&lt;&lt;endl;
    cout&lt;&lt;"create BST " &lt;&lt; root-&gt;getVal() &lt;&lt;endl;
    for(int i=1;i&lt;arr_size;i++){
        cout&lt;&lt;"create BST " &lt;&lt; root-&gt;getVal() &lt;&lt;endl;
        int curr_val = *(arr+i);
        placeNode(root,curr_val);
    }
    cout&lt;&lt;"create BST " &lt;&lt; root-&gt;getVal() &lt;&lt;endl;
    return obj_bst;
}

void placeNode(BST_Node* root, int curr_val){
    int root_val = root-&gt;getVal();
    if((curr_val&gt;root_val) &amp;&amp; (root-&gt;getRight()!=nullptr) ){
        placeNode(root-&gt;getRight(), curr_val);
    }else if((curr_val&lt;=root_val) &amp;&amp; (root-&gt;getLeft()!=nullptr)){
        placeNode(root-&gt;getLeft(), curr_val);
    }else if((curr_val&gt;root_val) &amp;&amp; (root-&gt;getRight()==nullptr)){


        BST_Node node(curr_val);
        root-&gt;setRight(&amp;node);
    }else if((curr_val&lt;=root_val) &amp;&amp; (root-&gt;getLeft()==nullptr)){
        BST_Node node(curr_val);
        root-&gt;setLeft(&amp;node);
    }else{
        cout&lt;&lt; "Placement denied" &lt;&lt; endl;
    }

}

//void createBST(int* arr, int arr_size);
int main(){
    int arr[10] = {23,23,34,1,2,343,343,23,4343};
    cout&lt;&lt;"working"&lt;&lt;endl;
    BST obj_bst = createBST(arr, 10);//sizeof(arr)/sizeof(int)
    cout&lt;&lt;"working"&lt;&lt;endl;
    BST_Node root = *(obj_bst.getBSTRoot());
    cout&lt;&lt;"working"&lt;&lt;endl;
    print_inorder(root);
    cout&lt;&lt;"working"&lt;&lt;endl;
    return 0;
}
</code></pre>

<p>The output I got is:
"
working
0 
1: 23
"
The execution stops after "root->setVal(*arr);" line in the "createBST" method. Any explanation would be highly appreciated. Thanks!</p>

<p>Sorry about too much code. I did not know what else could have been done here to post the question.</p>
