What wrong with BST : <p>I want to print all the key in BST. Why it printing only "the tree is empty" It just printing the tree is empty 2 times.
my coding first method is about creating a node to be a leaf and second is creating the leaf into the tree and thrid is printing the tree by inorder.
  If my coding is too bad can you fix it?                  </p>

<pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;

class BST
{
    private:
        struct Node
        {
            int key;
            Node *left;
            Node *right;
        };
        Node* root;
        Node* createLeafPrivate(int key,Node* ptr);
        void addLeafPrivate(int key,Node* ptr);
        void printInoderPrivate(Node* ptr);
    public:
        BST():root(nullptr){}
        Node* createLeaf(int key);
        void addLeaf(int key);
        void printInorder();


};
BST::Node* BST::createLeaf(int key)
{
    Node* newNode=new Node();
    newNode-&gt;key=key;
    newNode-&gt;left=nullptr;
    newNode-&gt;right=nullptr;
    return newNode;
}
void BST::addLeaf(int key)
{
    addLeafPrivate(key,root);
}
void BST::addLeafPrivate(int key,Node* Ptr)
{
    if(root == nullptr)
        root=createLeaf(key);
    else if (key &lt; Ptr-&gt;key)
    {
        if(Ptr-&gt;left != nullptr)
            addLeafPrivate(key,Ptr-&gt;left);
        else
            Ptr-&gt;left=createLeaf(key);
    }
    else if (key &gt; Ptr-&gt;key)
    {
        if(Ptr-&gt;right != nullptr)
            addLeafPrivate(key,Ptr-&gt;right);
        else
            Ptr-&gt;right=createLeaf(key);
    }
    else
    {
        std::cout&lt;&lt;"The key "&lt;&lt;key&lt;&lt;"has already been added to the tree\n";
    }
}
void BST::printInorder()
{
    printInoderPrivate(root);
}
void BST::printInoderPrivate(Node* Ptr)
{
    if(root != nullptr)
    {
        if(Ptr-&gt;left != nullptr)
            printInoderPrivate(Ptr-&gt;left);
        std::cout&lt;&lt;Ptr-&gt;key&lt;&lt;" ";
        if(Ptr-&gt;right != nullptr)
            printInoderPrivate(Ptr-&gt;right);
    }
    else
    {
        std::cout&lt;&lt;"The tree is empty\n";
    }
}

int main()
{
    BST myTree;
    std::cout&lt;&lt;"----Printing the empty tree----\n";
    myTree.printInorder();
    for(int i=16;i&lt;=0;i--)
        myTree.addLeaf(i);
    std::cout&lt;&lt;"----Printing the data tree-----\n";
    myTree.printInorder();
    std::cout&lt;&lt;std::endl;

    return 0;
}


</code></pre>
