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 to 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 } //+------------------------------------------------------------------+
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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