ok here it is

file: **bst.hpp:**

Code:

#include <queue>
template <class T>
class bst {
private:
struct sNode {
T data;
sNode *left;
sNode *right;
}
*root;
queue <sNode*> q;
sNode* insert (sNode*, T&);
void inorder (sNode*);
public:
bst ();
~bst ();
void insert (T); //insert data
void inorder (); //print inordered data
};

file: **bst.cpp**

Code:

#include <iostream>
using namespace std;
//! CONSTRUCTOR
template <class T>
bst<T>::bst () {
root = NULL;
}
//! DESTRUCTOR
template <class T>
bst<T>::~bst () {}
//! INSERT
template <class T>
void bst<T>::insert (T data) {
if (root == NULL) {
root = new sNode;
root->data = data;
root->left = NULL;
root->right = NULL;
}
else {
//sNode *tmp = insert (root, data);
}
}
template <class T>
bst<T>::sNode* bst<T>::insert (bst<T>::sNode *node, T &data) {
if (data == node->data) //already exists
return NULL;
sNode *tmp;
if (data < node->data) { //minus
if (node->left == NULL) {
tmp = node;
}
else {
tmp = insert (node->left, data);
}
}
else if (data > node->data) { //major
if (node->right == NULL) {
tmp = node;
}
else {
tmp = insert (node->right, data);
}
}
return tmp;
}
//! INORDER
template <class T>
void bst<T>::inorder () {
if (root != NULL)
inorder (root);
else
cout << "empty\n";
}
template <class T>
void bst<T>::inorder (sNode* node) {
if (node->left != NULL)
inorder (node->left);
cout << node->data;
if (node->right != NULL)
inorder (node->right);
}