This will work if you become TreeTop static:
class BinaryTree
{
private :
static Tree<T> *TreeTop;
unsigned int numberOfElements;
public :
void insertData (T data1,Tree<T> *tree=TreeTop);
}
In this case, it will be the default for the class to call the insertData method. If you want to set the default level at the instance level, you will need to do something like
class BinaryTree
{
private :
Tree<T> *TreeTop;
unsigned int numberOfElements;
public :
void insertData (T data1,Tree<T> *tree=NULL);
}
Then in your implementation do
public void BinaryTree::insertData(T data1, Tree<T> *tree)
{
if (tree==null) tree=TreeTop;
...
}
source
share