I have friend function in the class. (in header file. head.h) i have implemented in head.cpp and in head.h outside of the class i have ostream& operator<< (ostream& out, TreeNode* ptr); i implemented in head.cpp as well. Is there any problem with that?
Header file
friend ostream& operator<< (ostream& out, const TreeDB& ptr);
ostream& operator<< (ostream& out, TreeNode* ptr);
Implementation
ostream& operator<< (ostream& out, TreeNode* ptr)
{
if(rhs!=NULL)
{
operator<<(out,ptr->Left());
out<<(*(ptr->Entry()));
operator<<(out,ptr->Right());
}
return out;
}
ostream& operator<< (ostream& out, const TreeDB& ptr)
{
return (operator<<(out,ptr.root));
}
Error: undefined reference to 'operator<<(std::basic_ostream >&,DBentry const&)'
DBentry is another class which manipulates the database entry