We are working on a header file for a template class called TreeNode. My class definition is as follows:
#include <iostream>
using namespace std;
template <class T> class BSTree;
class TreeNode<T>;
{
friend classBSTree<T>;
public:
//constructor
TreeNode( T = T(), TreeNode<T>* = 0, TreeNode<T>* = 0 );
private:
T data; //holds data of interest
TreeNode<T> *linkL; //pointer to left link
TreeNode<T> *linkR; //pointer to right link
};//end TreeNode
I am unclear on what the argument T = T() means. It was given by the instructor. I understand that it is an argument of type T being initialized. But, don't get what it means to initialize to T()? This leads me to the problem of writing the implementation portion of the header.
This is what I want to write for the function header for the constructor:
TreeNode<T>::TreeNode(T d, TreeNode<T> right, TreeNode<T> left)
{
data = d;
linkR = right;
linkL = left;
}
I am really not looking for any code per se. But, would really appreciate a thorough explanation geared toward a novice programmer.
Thanks in Advance.