我正试图在C++中编制一份包含几何数据的清单。 清单是三角名单:
class Triangle
{
public:
Triangle(Point P1, Point P2, Point P3);
Triangle(const Triangle& T);
~Triangle() {delete e1; delete e2; delete e3;}
const Triangle operator=(const Triangle & T);
bool InCircle(Point & P);
int TriNumber() { return TriangleNumber;}
void SetTriNumber(int trinum) { TriangleNumber = trinum;}
Edge ReturnEdge(int i);
Point ReturnPoint(int i);
protected:
Point p1,p2,p3;
Edge *e1, *e2, *e3;
int TriangleNumber;
};
然而,当我试图制定三角名单时,我会利用以下线出现分裂:
const Point p1(100.0, 100.0);
const Point p2(-100.0, 100.0);
const Point p3(0.0, -150.0);
Triangle TT(p1,p2,p3);
list<Triangle> trilist;
list<Triangle>::iterator iter;
iter = trilist.begin();
// the next line is causing all the problems:
trilist.insert(iter, TT);
非常感谢任何帮助。