Download MetaTrader 5
To add comments, please log in or register
Order the development and track its status via your mobile phone.
Carl Schreiber
5927
Carl Schreiber 2014.03.09 19:56 

I define a struct:

struct TradeSet {
        double IniTgt, IniStp, PTS, PIP;
        string Symb, Descr, Full;
        int Magic, DIG, BuTckt, SeTckt; 
};

Now I just want to copy (move within the list) one element :

TradeSet arr[];
...
TradeSet tmp;
tmp = arr[i];
...
arr[j] = tmp

But the compiler complains:

'=' - structure have objects and cannot be copied       myEA_v2.mq4     360     7
'=' - structure have objects and cannot be copied       myEA_v2.mq4     366    10

So is there a more intelligent way to copy a struct that to write my own function that copies each single element one by one?

Gooly

GreenMoney
379
GreenMoney 2014.03.09 20:52  

I think the issue is the inclusion of the strings in your struct definition.

(From the documentation: Structures and Classes):

Simple Structures

Structures that do not contain strings or objects of dynamic arrays are called simple structures; variables of such structures can be freely copied to each other, even if they are different structures. Variables of simple structures, as well as their array can be passed as parameters to functions imported from DLL.

.

/
To add comments, please log in or register