我在课堂上有朋友功能。(在头文件中。head.h)我已经在head.cpp和head.h中实现了类外我有ostream& operator<< (ostream& out, TreeNode* ptr); 我也在 head.cpp 中实现。这有什么问题吗?
头文件
friend ostream& operator<< (ostream& out, const TreeDB& ptr);
ostream& operator<< (ostream& out, TreeNode* ptr);
执行
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));
}
错误:未定义对 'operator<<(std::basic_ostream >&,DBentry const&)' 的引用
DBentry 是另一个操作数据库条目的类