Problem using a copy constructor

To add comments, please log in or register
Geester
171
Geester  

Hi there,

I have a private class variable _confirmedPivots that I use to contain pivots from a different collection (of the same type) that have "confirmed" (by the rules of my methodology). I create a copy of the source CHiLo object (see below) and add it to _confirmedPivots collection. When this process is complete, I send the Clear() message to the source collection. This leaves an empty source collection and theoretically, a subset of copied "confirmed" pivots in _confirmedPivots. However, despite _confirmedPivots.Total() reporting the exact number of confirmed pivots, if I try and access an item, I get a "bad pointer" error.

I'm new to the MQL language and here is my question. Using a copy constructor, should the resultant object be completely independent of the source of the copy? Despite making this copy, it seems that the deletion of the original object is causing this issue.

Any advice would be much appreciated.

Cheers,

--G

private:
CObjVector<CHiLo>_confirmedPivots;

...

CHiLo *highToAdd=highestHigh;
_confirmedPivots.Add(highToAdd);
To add comments, please log in or register