Hi everyone

I have defined list of CPoints as follows:

typdef CList AllPts;

I have defined a CSegment class as follows. My CSegment class among other
parameters has a list of points.

Class CSegment

AllPts m_pts;

Then I wanted to have a list of Segments so I define allSegments as follows:

typdef std::vector AllSegs;

Then somewhere in my application I have defined a parameter of type AllSegs
as follow:

AllSegs m_segs;

In my application there are many places where I do assignments like these:

CSegment seg1;
CSegment seg2;
// ... filling seg1
seg2 = seg1;


AllSegs segs1;
AllSegs segs2;
// ... filling segs1
segs2 = segs1

However in my application when number of segments added to m_segs pass a
certain number, application crashes at "HeapValidate" function of
"heapchk.c" with Unhandled exception error.

I though that I need to add copy and assignment constructor to my CSegment
class, so I added the following functions to my CSegment class:

//copy constructor
CSegment::CSegment(const CSegment& other)
*this = other;

//assignment constructor
CSegment& CSegment:perator= (CSegment const & other)
if (this != &other)
POSITION pos = other.m_pl.GetHeadPosition();
while( pos != NULL )
CPoint pt = other.m_pts.GetNext(pos);

//.... other members assignment

return *this;

But I still get that HeapValidate error and somehow I can see that some
segments are aggregated from other segments.
It seems to me that sometimes constructors are called twice for an object!!

Could anyone please check if my copy and assignment constructors are
corectly defined?

Thanks in advance,