Creating an Array of object, getting error

 

Hi

Sorry asking simple question, I am very new and trying to learn MQL4 programming with MT4.

I am trying to create an Array of objects. as shown below; But I a getting error and finding it difficult to fix. 

Please can someone help 

***

Thank you

 
Please try to post in the correct section of the forum, and also try to format your source code properly.
 
ishf fady :

Hi

Sorry asking simple question, I am very new and trying to learn MQL4 programming with MT4.

I am trying to create an Array of objects. as shown below; But I a getting error and finding it difficult to fix. 

Please can someone help 

***

Thank you

Please insert the code correctly: when editing a message, use the button Codeto insert the code.

 
Here is the code

#property strict
//+------------------------------------------------------------------+

class CurrencyCount{
   public:
      string currency;
      int count;
        
   public:
   CurrencyCount(){};
   CurrencyCount(string incurrency, int incount){
      this.currency = incurrency;
      this.count = incount;
   };
};
//+------------------------------------------------------------------+

void OnStart(){
     CurrencyCount currencyCount1("USD", 2);
     CurrencyCount currencyCount2("GBP", 5);
     CurrencyCount currencyCount3("JPY", 4);
     CurrencyCount currencyCount4("CAD", 1);
     CurrencyCount currencyCount5("NZD", 3);
     CurrencyCount myCurrencyCount[4] = {currencyCount1, currencyCount2, currencyCount3, currencyCount4};
}
 
ishf fady:

try this...

#property strict
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class CurrencyCount
  {
public:
   string            currency;
   int               count;

public:
                     CurrencyCount() {};
                     CurrencyCount(string incurrency, int incount)
     {
      this.currency = incurrency;
      this.count = incount;
     };
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnStart()
  {
   CurrencyCount currencyCount1("USD", 2);
   CurrencyCount currencyCount2("GBP", 5);
   CurrencyCount currencyCount3("JPY", 4);
   CurrencyCount currencyCount4("CAD", 1);
   CurrencyCount currencyCount5("NZD", 3);
   CurrencyCount myCurrencyCount[5];
   myCurrencyCount[0]=currencyCount1;
   myCurrencyCount[1]=currencyCount2;
   myCurrencyCount[2]=currencyCount3;
   myCurrencyCount[3]=currencyCount4;
   myCurrencyCount[4]=currencyCount5;
   Print(myCurrencyCount[4].currency," ",myCurrencyCount[4].count);
//output:
//NZD 3
  }
//+------------------------------------------------------------------+
 

Thank you very much Tsungche Kuo 

Much appreciated, I was struggling for some time with this problem.