Hi all. I am having a hard time trying to properly declare a header for my assignment overload operator function.

My prototype for the function is:

const BSTree<T>& operator=(const BSTree<T>&);

And my attempt to write the header for the method is as follows:

template <class T>
const BSTree<T> BSTree<T>::operator=(const BSTree<T> & copyRoot)
{
return copyRoot;
}

Obviously it doesnt do anything inside the method, but my main aim is to get the program to compile without errors, then i will concentrate on the body of the method. The errors i get when trying to compile make me confused, so i was hoping if i give them, someone can help me out ...

here are the errors:
80 BSTree.h prototype for `const BSTree<T> BSTree<T>::operator=(const BSTree<T>&)' does not match any in class `BSTree<T>'
75 assign8\BSTree.h const BSTree<T>& BSTree<T>::operator=(const BSTree<T>&)
80 assign8\BSTree.h template definition of non-template `const BSTree<T> BSTree<T>::operator=(const BSTree<T>&)'

Hope these errors make sense to someone else... any help would be greatly appreciated as always.

Thank you folks

You are missing a & in the definition. The return type in the declaration is

const BSTree<T>&

but in the definition its

const BSTree<T>

Great - thank you for your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.