Set array member value inside class function?

Back to topics list To post a new topic, please log in or register
avatar
108
HarriMQL5 2016.08.25 15:33
 

Hello


Im trying to copy the value of a member of an array to another position in the same array. I get the error:

'=' not allowed for objects with protected members or inheritance


but I dont understand why I get this. Can someone help please?


Code:

class COrderEntry
{
    private:
        #define ORDSZ   100
        int obias;
        int oidx;
        int oidx2;
    
        COrderEntry orderLs[];
        
    public:
         COrderEntry(int pBias = 0);
         void COrderAddOrder(long pTicket, double pOOP);
        ~COrderEntry();
};
//+------------------------------------------------------------------+
void COrderEntry::COrderAddOrder(long pTicket, double pOOP) {
    int arrSz;

    arrSz = ArraySize(orderLs);

    if (arrSz < ORDSZ) {
        ArraySetAsSeries(orderLs, false);
        ArrayResize(orderLs, arrSz + 1);
        ArraySetAsSeries(orderLs, true);
    }
    else
    {
        for (int x=arrSz-1; x>0; x--)
            orderLs[x] = orderLs[x-1];
    }    
    
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
COrderEntry::COrderEntry(int pBias = 0)
{
    obias = pBias;
    oidx = (1-obias)/2; oidx2 = (1+obias)/2;
    ArraySetAsSeries(orderLs, true);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
COrderEntry::~COrderEntry()
{
}
avatar
1111
Ovo 2016.08.25 15:54 #
 
Try to create a copy constructor.
avatar
108
HarriMQL5 2016.08.25 16:06 #
 

Ok, I see how that can work.

Also, I found https://forum.mql4.com/66769 which helped


Thank you!

Back to topics list  

To add comments, please log in or register