【发布时间】:2011-10-24 06:19:04
【问题描述】:
我在尝试实现一个重载的
class NURBScurve {
vector<double> knotVector;
int curveOrder;
list<Point> points;
public:
/* some member functions */
friend ostream& operator<< (ostream& out, const NURBScurve& curve);
};
我感兴趣的关键成员变量是“点”列表——这是我创建的另一个类,它存储点的坐标以及相关的成员函数。当我尝试将重载的
ostream& operator<<( ostream &out, const NURBScurve &curve)
{
out << "Control points: " << endl;
list<Point>::iterator it;
for (it = curve.points.begin(); it != curve.points.end(); it++)
out << *it;
out << endl;
return out;
}
我开始遇到问题。具体来说,我收到以下错误: 错误:
no match for ‘operator=’ in ‘it = curve->NURBScurve::points. std::list<_Tp, _Alloc>::begin [with _Tp = Point, _Alloc = std::allocator<Point>]()’
/usr/include/c++/4.2.1/bits/stl_list.h:113: note: candidates are: std::_List_iterator<Point>& std::_List_iterator<Point>::operator=(const std::_List_iterator<Point>&)
我在这里有点难过,但我相信这与我正在使用的列表迭代器有关。我对curve.points.begin()的符号也不太自信。
如果有人能对这个问题有所了解,我将不胜感激。我正处于我盯着这个问题太久的地步!
【问题讨论】:
-
你可以试试pretty printer :-)