【发布时间】:2012-08-21 05:26:46
【问题描述】:
我目前正在尝试重载 '
在函数'std::ostream& operator
重载的运算符函数在Linkedlist实现文件中被声明为友元成员函数,因为它会访问一个私有成员变量(head_ptr):
std::ostream& operator <<(std::ostream& outs, const Linkedlist& source)
{
node* cursor;
for(cursor = source.get_head(); cursor != NULL; cursor = cursor->fetchLink())
{
outs << cursor->fetchData() << " ";
}
return(outs);
}
这是Linkedlist头文件中的函数原型:
friend std::ostream& operator <<(std::ostream& outs, const Linkedlist& source);
我已经爬网了,到目前为止还没有找到解决方案。任何建议都会很棒!
【问题讨论】:
标签: c++ overloading operator-keyword