Download MetaTrader 5
To add comments, please log in or register
Having questions to the author of an article? Discuss them on the Forum!
HarriMQL5
285
HarriMQL5 2016.08.25 13: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()
{
}
Ovo Cz
2956
Ovo Cz 2016.08.25 13:54  
Try to create a copy constructor.
HarriMQL5
285
HarriMQL5 2016.08.25 14:06  

Ok, I see how that can work.

Also, I found https://www.mql5.com/en/forum/154829 which helped


Thank you!

/
To add comments, please log in or register