Hello Everyone,
From the best of my knowledge, both of these are used within mql4.
Question: Why would you choose one over the other and why?
This tutorial for C++ gives a good example for where you use both:
https://www.tutorialspoint.com/cplusplus/cpp_interfaces.htm
Obviously, the syntax is slightly different from MQL4.
The gist of the example is that all shapes have an area, but the area is calculated differently. So:
1. You create an interface and specify a virtual function getArea().
2. You derive all shape classes from this interface.
3. You override the getArea() function in each class.
The interface basically guarantees that you (as a programmer) don't forget to implement the getArea() function in each derived class.
That guarantee, i.e. the requirement to implement the getArea() function in each and every derived shape class, is why you use an interface. It keeps the naming consistent and forces you to implement.
You could easily extend this interface by adding getPerimeter(), since all shapes have a perimeter.
- tutorialspoint.com
- www.tutorialspoint.com
Hello again,
Thank you for your response. I have just started an online programming course. The course has shown me so far that a lot of things that I have be doing in any programming language are at times total nonsense. I have found that some of the codes I wrote years ago aren't "DRY". Some of them I have thought about re-writing or completely deleting them and starting over again.
Not directly related, but interface in MQL5 is a limited version of what interface is supposed to be, which is a contract for specific behaviour implementation. The limit on MQL5 comes from the fact that a class can not extend another class and one or more interfaces at the same time, which makes it pretty useless in MQL5.
Welcome to the discussion,
Maybe save a return value/s. Give the return back to the class/s. Then save return valves to file and retrieve them in order to assigned class.
Welcome to the discussion,
Maybe save a return value/s. Give the return back to the class/s. Then save return valves to file and retrieve them in order to assigned class.
Hello friend,
Where did you think bool can equal a Trendline?
Secondly price can't really be true, or false.. can they!
Might be channel can be +- value & TrendLine can be another value....
Price can be up and down.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello Everyone,
From the best of my knowledge, both of these are used within mql4.
Question: Why would you choose one over the other and why?