I have included below the class declarations and the struct I am using in my program.
I am getting the following 3 error msg's:
Cannot convert 'int' to 'Word' in functions BSTree<Word>::isEmpty() const
Cannot convert 'char*' to 'Word' in function List::readList()
Type mismatch in parameter 'data' in call to 'BSTree<Word>::insertData(const Word&)' in function List::readList()
Can someone pls help me with this because I am totally lost
Code:
template <class T>
class BTNode
{
friend class BSTree<T>;
private:
BTNode (){left=right=NULL;}
BTNode (const T& el){info = el; left=right=NULL;}
T info;
BTNode<T> *left;
BTNode<T> *right;
};
Code:
template <class T>
class BSTree
{
friend class List;
public:
BSTree (){root=NULL;};
BSTree (const BSTree<T>& rhs);
BSTree<T>& operator= (const BSTree<T>& rhs);
~BSTree (){clear(root);}
T isEmpty () const {return root==NULL;}
void insertData (const T& data);
private:
BTNode<T> *root;
void clear (BTNode<T> *treeRoot);
BTNode<T> *copyTree (BTNode<T> *treeRoot);
void insertHelper (BTNode<T> *&treeRoot, const T&
data);
void printInOrder (BTNode<T> *treeRoot);
int countNodes (BTNode<T> *treeRoot);
};
Code:
const int MAX=20;
struct Word
{
char wrd[MAX];
};
Code:
class List
{
public:
void readList ();
private:
Word x; //struct obj
};
//==============================
void Dict::readList ()
{
BSTree<Word> tmp; //BSTree has type struct
ifstream infile;
infile.open ("wrdlist.txt");
infile >> x.wrd;
tmp.insertData (x.wrd);
infile.close();
}