unresolved static variable

 
struct myMqlTradeResult: MqlTradeResult
  {
public:
   bool              isSuccessful;
  };

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class myTransaction
  {
public:
   myMqlTradeResult  result;
   MqlTradeRequest    request;

  };


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class CMyCommand
  {
private:


public:
   static myTransaction lstTransactions[];
   
   static void  CMyCommand::AddTransaction(MqlTradeRequest &_request, myMqlTradeResult &_result)
     {
      myTransaction t;   
      t.request =_request;
      t.result=_result;
      
      ArrayResize(CMyCommand::lstTransactions,ArraySize(CMyCommand::lstTransactions)+1);   //unresolved static variable 'CMyCommand::lstTransactions'   MyCommand.mqh   55      31

      CMyCommand::lstTransactions[ArraySize(CMyCommand::lstTransactions)-1]=t;
     }
 }

I am getting the compilation error:    unresolved static variable 'CMyCommand::lstTransactions'   

Any ideas?

 
Giannos Antoniou:

I am getting the compilation error:    unresolved static variable 'CMyCommand::lstTransactions'   

Any ideas?

Don't use static variable

 
 
William Roeder:

Perhaps you should read the manual. Especially the first example.
          Language Basics / Object-Oriented Programming / Static Members of a Class - Reference on algorithmic/automated trading language for MetaTrader 5

I got your point. I should give initial value to the static array.  However, If I do it, how can i resize the array? My goal is to use it as a List<myTransaction> in order to add and remove items.

If this approach is not proper, could you suggest me another approach, please?

 
Giannos Antoniou: I should give initial value to the static array.  However, If I do it, how can i resize the array?
  1. How can you give initial values to an array with no size?
  2. You already posted code that resizes an array. You already know how.
This website uses cookies. Learn more about our Cookies Policy.