When there is no implicit constructor in the class you extend, you must explicitly call it:
myEMA(int period, int shift):myMovingAverage(period, shift) { this.maMethod = MODE_EMA; }
- You must construct the base class in a initialization list. Structures and Classes - MQL4 Documentation
myEMA::myEMA(int period, int shift) : myMovingAverage(period, shift){}
this.maPeriod = period;
You don't need the "this."this.maMethod = MODE_EMA;
maMethod is a private variable, will not compile.
Thanks guys, the compiler went through with no errors.
Nice to see you're still kicking around WHRoeder, you were helping me with coding issues in like 2010.
Does it matter if I use the "this." operator in the code? It just helps me personally read the code better from an OOP point of view.
I guess the correct question would be, would there be any negative effect of using the this statement?
dazamate: Does it matter if I use the "this." operator in the code? It just helps me personally read the code better from an OOP point of view.
Makes no difference. Most name their member variables mVariable, myVariable, or _variable to differentiate from local variables; this.variable is too verbose for me.
I am used to web languages, it's good practice for me :)

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
Hey everyone, learning to uses classes to neaten up my coding and get with the times.
I am doing a basic moving average class set. I have created the base moving average class - which seems to work ok. Now I am trying to make an exponential moving average extended class, but having a bit of trouble with the syntax...
Now when I try to set up the child class I get a compile error...
I am guessing it is because the base class takes parameters in the constructor. I also tried...
I am still getting a wrong parameters count error for the constructor. Please help set me straight.