Help With Binary Tree Template

When I compile the program, I get errors I've never seen before. Any help to resolve this will be appreciated. Here's my program:

Header File
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef BINARYTREE_H
#define BINARYTREE_H

#include <iostream>
using namespace std;

template <class T>
class BinaryTree
{
	private:
		struct TreeNode
		{
		   T value;
		   TreeNode *left;
		   TreeNode *right;
		};

		TreeNode *root;

		void insert(TreeNode *&, TreeNode *&);
		void destroySubTree(TreeNode *);
		void deleteNode(T, TreeNode *&);
		void makeDeletion(TreeNode *&);
		void displayInOrder(TreeNode *) const;
		void displayPreOrder(TreeNode *) const;
		void displayPostOrder(TreeNode *) const;

	public:
		BinaryTree()
		{
		   root = NULL;
		}

		~BinaryTree()
		{
		   destroySubTree(root);
		}

		void insertNode(T);
		bool searchNode(T);
		void remove(T);

		void displayInOrder() const
		{
		   displayInOrder(root);
		}

		void displayPreOrder() const
		{
		   displayPreOrder(root);
		}

		void displayPostOrder() const
		{
		   displayPostOrder(root);
		}
};
#endif 


Cpp File
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include "BinaryTree.h"

template<class T>
void BinaryTree<T>::insert(TreeNode *&nodePtr, TreeNode *&newNode)
{
	if(nodePtr == NULL)
	   nodePtr = newNode;

	else if(newNode -> value < nodePtr -> value)
	   insert(nodePtr -> left, newNode);

	else
	   insert(nodePtr -> right, newNode);
}

template<class T>
void BinaryTree<T>::insertNode(T num)
{
	TreeNode *newNode;

	newNode = new TreeNode;
	newNode -> value = num;
	newNode -> left = newNode -> right = NULL;

	insert(root, newNode);
}

template<class T>
void BinaryTree<T>::destroySubTree(TreeNode *nodePtr)
{
	if(nodePtr)
	{
	   if(nodePtr -> left)
		destroySubTree(nodePtr -> left);

	if(nodePtr -> right)
		destroySubTree(nodePtr -> right);

	delete nodePtr;
	}
}

template<class T>
bool BinaryTree<T>::searchNode(T num)
{
	TreeNode *nodePtr = root;

	while(nodePtr)
	{
	   if(nodePtr -> value == num)
		return true;

	   else if (num < nodePtr -> value)
		nodePtr = nodePtr -> left;

	   else
		nodePtr = nodePtr -> right;
	}

	return false;
}

template<class T>
void BinaryTree<T>::remove(T num)
{
	deleteNode(num, root);
}

template<class T>
void BinaryTree<T>::deleteNode(T num, TreeNode *&nodePtr)
{
	if(num < nodePtr -> value)
	   deleteNode(num, nodePtr -> left);

	else if(num > nodePtr -> value)
	   deleteNode(num, nodePtr -> right);

	else
	   makeDeletion(nodePtr);
}

template<class T>
void BinaryTree<T>::makeDeletion(TreeNode *&nodePtr)
{
	TreeNode *tempNodePtr;

	if(nodePtr == NULL)
		cout << "\nError: Cannot Delete Empty Node.";

	else if(nodePtr -> right == NULL)
	{
	   tempNodePtr = nodePtr;
	   nodePtr = nodePtr -> left;
	   delete tempNodePtr;
	}

	else if(nodePtr -> left == NULL)
	{
	   tempNodePtr = nodePtr;
           nodePtr = nodePtr -> right;
	   delete tempNodePtr;
	}

	else
	{
	   tempNodePtr = nodePtr -> right;

	   while(tempNodePtr -> left)
		tempNodePtr = tempNodePtr -> left;

	   tempNodePtr -> left = nodePtr -> left;
	   tempNodePtr = nodePtr;
	   nodePtr = nodePtr -> right;
	   delete tempNodePtr;
	}
}

template<class T>
void BinaryTree<T>::displayInOrder(TreeNode *nodePtr) const
{
	if(nodePtr)
	{
	   displayInOrder(nodePtr -> left);
	   cout << nodePtr -> value;
	   displayInOrder(nodePtr -> right);
	}
}

template<class T>
void BinaryTree<T>::displayPreOrder(TreeNode *nodePtr) const
{
	if(nodePtr)
	{
	   cout << nodePtr -> value;
	   displayPreOrder(nodePtr -> left);
	   displayPreOrder(nodePtr -> right);
	}
}

template<class T>
void BinaryTree<T>::displayPostOrder(TreeNode *nodePtr) const
{
	if(nodePtr)
	{
	   displayPostOrder(nodePtr -> left);
	   displayPostOrder(nodePtr -> right);
	   cout << nodePtr -> value;
	}
}


Main file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "BinaryTree.h"
#include <string>

const int NUM_NODES = 5;

int main(void)
{
   string num;
   BinaryTree <string> tree;

   for(int count = 0; count < NUM_NODES; count++)
   {
	cout << "\nEnter a Value: ";
	getline(cin, num);
	tree.insertNode(num);
   }

   cout << "\nHere Are the Values in the Tree:\n";
   tree.displayInOrder();

   cout << "\n\n";
}


And my errors
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall BinaryTree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::insertNode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?insertNode@?$BinaryTree@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main

1>main.obj : error LNK2019: unresolved external symbol "private: void __thiscall BinaryTree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::destroySubTree(struct BinaryTree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::TreeNode *)" (?destroySubTree@?$BinaryTree@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@AAEXPAUTreeNode@1@@Z) referenced in function "public: __thiscall BinaryTree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::~BinaryTree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(void)" (??1?$BinaryTree@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAE@XZ)

1>main.obj : error LNK2019: unresolved external symbol "private: void __thiscall BinaryTree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::displayInOrder(struct BinaryTree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::TreeNode *)const " (?displayInOrder@?$BinaryTree@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@ABEXPAUTreeNode@1@@Z) referenced in function "public: void __thiscall BinaryTree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::displayInOrder(void)const " (?displayInOrder@?$BinaryTree@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QBEXXZ)
Thanks ne555
Topic archived. No new replies allowed.