icelantic 0 Newbie Poster

I have to write a template function that tells me if two binary trees are equal in structure and in data. However whenever i call the function in my testing code, it tells me I have an undefined reference to it. I'm not sure what this means or how to fix it, any help is appreciated.

header file

#include <iostream>
#include <cassert>
#include <cstdlib>
#include <stack>
#include <queue>



namespace assignment4
{
	template <class Item>
	class binary_tree_node
	{
	public:
		binary_tree_node(const Item& init_data = Item( ),
		binary_tree_node *init_left = NULL,
		binary_tree_node *init_right = NULL);
		Item& data( ) {return data_field;}
		binary_tree_node*& left( ) {return left_field;}
		binary_tree_node*& right( ) {return right_field;}
		void set_data(const Item& new_data) {data_field = new_data;}
		void set_left(binary_tree_node *new_left) {left_field = new_left;}
		void set_right(binary_tree_node *new_right) {right_field = new_right;}
		bool is_double( ) const
		{
			if(left_field != NULL && right_field != NULL)
			{
				return true;
			}
			return false;
		}
		bool is_leaf( ) const
		{
			if(left_field == NULL && right_field == NULL)
			{
				return true;
			}
			return false;
		}
		bool is_single_parent_left() const
		{
			if(right_field == NULL && left_field != NULL)
			{
				return true;
			}
			return false;
		}
		bool is_single_parent_right() const
		{
			if(left_field == NULL && right_field != NULL)
			{
				return true;
			}
			return false;
		}

	private:
		Item data_field;
		binary_tree_node *left_field;
		binary_tree_node *right_field;
	};

	template <class Item>
	bool tree_equal ( binary_tree_node<Item> *t1, binary_tree_node<Item> *t2)
	{

		if(t1->is_leaf() && t2->is_leaf())
		{
			if(t1->data() == t2->data())
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		if(t1->is_single_parent_left() && t2->is_single_parent_left())
		{
			if(t1->data() == t2->data())
			{
				tree_equal(t1->left(), t2->left());
			}
			else
			{
				return false;
			}
		}
		if(t1->is_single_parent_right() && t2->is_single_parent_right())
		{
			if(t1->data() == t2->data())
			{
				tree_equal(t1->right(), t2->right());
			}
			else
			{
				return false;
			}
		}
		if(t1->is_double() && t2->is_double())
		{
			if(t1->data() == t2->data())
			{
				tree_equal(t1->left(), t2->left());
				tree_equal(t1->right(), t2->right());
			}
			else
			{
				return false;
			}
		}
		if(t1->is_leaf() && t2->is_leaf() == false)
		{
			return false;
		}
		if(t2->is_leaf() && t1->is_leaf() == false)
		{
			return false;
		}
		if(t1->is_single_parent_left() && t2->is_single_parent_left() == false)
		{
			return false;
		}
		if(t2->is_single_parent_left() && t1->is_single_parent_left() == false)
		{
			return false;
		}
		if(t1->is_single_parent_right() && t2->is_single_parent_right() == false)
		{
			return false;
		}
		if(t2->is_single_parent_right() && t1->is_single_parent_right() == false)
		{
			return false;
		}
		if(t1->is_double() && t2->is_double() == false)
		{
			return false;
		}
		if(t2->is_double() && t1->is_double() == false)
		{
			return false;
		}

		return true;

	}

code that call it

// FILE: assignment4Exam.cxx
// Exam file for programming assignment 4
// Written by Shivakant Mishra
// Last Update: April 28, 2010

#include <iostream>
#include <cassert>    // Provides assert
#include <cstdlib>    // Provides NULL and size_t
#include <stack>    // STL stack
#include <queue>    // STL queue
#include "assignment4.h"
using namespace std;
using namespace assignment4;

int main( )
{
	

	binary_tree_node<int> n1(10), m1(10), l1(10);
	binary_tree_node<int> n2(20), m2(20), l2(20);
	binary_tree_node<int> n3(30), m3(30);
	binary_tree_node<int> n4(50, &n2, &n3), m4(50, &m2, &m3);
	binary_tree_node<int> n5(40, &n1, &n4), m5(40, &m1, &m4);
	binary_tree_node<int> l4(50, &l2), l5(40, &l1, &l4);

	if (tree_equal(&n5, &m5)) cout << "m and n are equal" << endl;
	else cout << "m and n are not equal" << endl;
	if (tree_equal(&n5, &l5)) cout << "l and n are equal" << endl;
	else cout << "l and n are not equal" << endl;
	if (tree_equal(&m5, &l5)) cout << "l and m are equal" << endl;
	else cout << "l and m are not equal" << endl;


}