I suggest you first take the time to read the documentation and to do some research into how to program in OOP (object oriented programming).
You will find a lot of research material on the web related to C++ OOP which is almost the same as MQL OOP.
I suggest you first take the time to read the documentation and to do some research into how to program in OOP (object oriented programming).
You will find a lot of research material on the web related to C++ OOP which is almost the same as MQL OOP.
Hez Fernando,
Thank you for your reply. I am constantly doing so, checking the documentation and online articles, but sometimes its like finding a Needle in a Haystack! Would you please point me more specifically to the part of the documentation where I can learn more about my questions? Really appreciate any small advices.
Cheers,
Zarik
CExpertSignal::CExpertSignal(void) : m_base_price(0.0), m_general(-1), // no "main" signal m_weight(1.0), m_patterns_usage(-1), // all models are used m_expiration(0), m_direction(EMPTY_VALUE) { }
The highlighted sections are simply the calling of default constructors to initialise the member variables.
You should read the documentation from start to finish as if reading a novel. The reason is not to memorise everything but to serve as an overview, an outline, so that you can later more easily reference it when you require more details.
EDIT: Please note that not all the specifics of OOP can be found in the MQL documentation. Plenty of it is not described, but since MQL is very similar to C++, you will find more details of C++ OOP at other sources found on the web.
Documentation on MQL5: Language Basics / Data Types / Structures, Classes and Interfaces
...
There is a special syntax to initialize an object using a constructor. Constructor initializers (special constructions for initialization) for the members of a struct or class can be specified in the initialization list.
An initialization list is a list of initializers separated by commas, which comes after the colon after the list of parameters of a constructor and precedes the body (goes before an opening brace). There are several requirements:
- Initialization lists can be used only in constructors;
- Parent members cannot be initialized in the initialization list;
- The initialization list must be followed by a definition (implementation) of a function.
Here is an example of several constructors for initializing class members.
//+------------------------------------------------------------------+ //| A class for storing the name of a character | //+------------------------------------------------------------------+ class CPerson { string m_first_name; // First name string m_second_name; // Second name public: //--- An empty default constructor CPerson() {Print(__FUNCTION__);}; //--- A parametric constructor CPerson(string full_name); //--- A constructor with an initialization list CPerson(string surname,string name): m_second_name(surname), m_first_name(name) {}; void PrintName(){PrintFormat("Name=%s Surname=%s",m_first_name,m_second_name);}; };
Documentation on MQL5: Language Basics / Data Types / Structures, Classes and Interfaces
...
There is a special syntax to initialize an object using a constructor. Constructor initializers (special constructions for initialization) for the members of a struct or class can be specified in the initialization list.
An initialization list is a list of initializers separated by commas, which comes after the colon after the list of parameters of a constructor and precedes the body (goes before an opening brace). There are several requirements:
- Initialization lists can be used only in constructors;
- Parent members cannot be initialized in the initialization list;
- The initialization list must be followed by a definition (implementation) of a function.
Here is an example of several constructors for initializing class members.
You pointed me to the answer, no just the topic! Thank you very much! 🙏
Zarik
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
Take a look at the class definition please:
And in the constructor:
What are these parameters with this values inside parenthesis? and What means ":" after the method's definition?
Thank you!
Cheers,
Zarik