A c++ binary tree program which sorts the number from small to large

My learning of c++ has gone so well and now I have reached the state which I can create my own binary tree program which will sort a set of numbers and rearranges them from small to large. Below are the full c++ code which creates that binary tree program.

#ifndef FNODE_H
#define FNODE_H

using namespace std;

class Fnode
{
    public:
        int val;
        Fnode* pLeft;
        Fnode* pRight;
        Fnode(int);

    protected:

    private:
};

#endif // FNODE_H

Fnode.h

#ifndef FTREE_H
#define FTREE_H

#include "Fnode.h"

using namespace std;

class Ftree
{
    public:
        Ftree();
        void insert(int);
        void print();

    protected:

    private:
        Fnode* root;
        Fnode* insert_sub_node(int, Fnode*);
        void print_sub(Fnode*);
};

#endif // FTREE_H

Ftree.h

#include "Fnode.h"
#include<string>

using namespace std;

Fnode::Fnode(int n)
{
    val = n;
    pLeft = NULL;
    pRight = NULL;
}

Fnode.cpp

#include "Ftree.h"

#include<string>
#include<iostream>

using namespace std;

Ftree::Ftree()
{
    root = NULL;
}

void Ftree :: insert(int n) {
    root = insert_sub_node(n, root);
}

void Ftree :: print() {
    print_sub(root);
}

Fnode* Ftree :: insert_sub_node(int n, Fnode* p) {
    if (!p) {
        return new Fnode(n);
    } else if (n < p->val) {
        p->pLeft = insert_sub_node(n, p->pLeft);
    } else if (n > p->val) {
        p->pRight = insert_sub_node(n, p->pRight);
    }
    return p;
}

void Ftree :: print_sub(Fnode* p) {
    if (p) {
        print_sub(p->pLeft);
        cout << p->val << endl;
        print_sub(p->pRight);
    }
}

Ftree.cpp

#include <iostream>
#include <fstream>

#include "Ftree.h"

using namespace std;

int main()
{
    Ftree f_tree;
    string prompt = "Enter a number (ENTER 0 when done): ";
    int value;
    while (true ) {
        cout << prompt;
        cin >> value;
        if (value == 0) { //terminate the program if the user enters 0
            break; 
        }
        f_tree.insert(value);
    }
    cout << "Here are the numbers in order." << endl;

    f_tree.print();
   
    return 0;
}

main.cpp

The program above takes the number input from the user and the first input will become the root node of the tree, the program above will also avoid duplicate value. The last part of the program simply prints out the numbers that have been sorted according to the small goes first principle.

Like this post? Kindly share!