Q:

C++ template binary tree implementation

My binary tree implementation looks something like this:
template <class T, template <class> class NodeType = BinaryTreeNode>
class BinaryTree : public Tree<T>
{
  int size;
  NodeType<T> *root;

  public:

  ~BinaryTree()
  {
    if(root != NULL)
    {
      delete root;
    }
  }
  BinaryTree()
  {
    this->size = 0;
    this->root = NULL;
  }

  bool create();
  bool insert(T p);
}

Now, i am having trouble calling BinaryTree::insert(T p).
If I do something like:
bool BinaryTree<class T, template <class> class BinaryTreeNode >::insert(T data)
{
  NodeType<T> *bNode = new NodeType<T>(data);
}

g++ throws the following error:

BinaryTree.cxx:11: error: template argument 2 is invalid

Actually, I copied the code:
template <class T, template <class> class NodeType = BinaryTreeNode>

from somewhere, but I dont understand it fully.
Can anyone please tell me how to call a function of this class and how is this template declaration working?

A:

Now, i am having trouble calling BinaryTree::insert(T p).

I believe that you've mixed up some words. It seems that you are not trying to call the function. You are defining the function.
This syntax is invalid for defining a member function of a template class:
bool BinaryTree<class T, template <class> class BinaryTreeNode >::insert(T data)

This is a correct version:
template <class T, template <class> class NodeType>
bool BinaryTree<T, NodeType>::insert(T data)

The implementation that you have immediately leaks the allocated data, but I assume it's still unfinished.

