Search code examples
structcompiler-errorsmql4mql5

Structure have objects and cannot be copied, despite no complex structures are present


I've got the following MQL code:

class Account {};

class Trade {

  protected:

    struct TradeParams {
      uint     slippage;   // Value of the maximum price slippage in points.
      Account *account;    // Pointer to Account class.
    };

    TradeParams trade_params;

  public:

     void Trade(TradeParams &_params) {
       trade_params = _params; // Error: '=' - structure have objects and cannot be copied.
     }

};

However, the MetaTrader platform doesn't compile the file due to the following error:

'=' - structure have objects and cannot be copied TestTrade.mqh 17 21

I'm using MetaEditor 5.00 build 1601 (May 2017).

I've checked this similar question, but my struct doesn't contain any complex objects such as strings. The suggestion is to use pointers instead of structures, which I am actually using. My goal is to have a class constructor with a struct argument as shown above.

What is wrong with above struct definition and how it can be corrected?


Solution

  • It seems this compiling issue has been fixed in the recent version of the platform.

    I've compiled the same code under MetaEditor v5.00 build 1745 and it worked fine.