Download MetaTrader 5

Checking the initializing a class thru a parametric constructor

To add comments, please log in or register
Sign up for MQL5.community to leave your comments!
Amir Yacoby
1192
Amir Yacoby 2015.04.18 17:14 
Hello,

When using a parametric constructor, what is your way of validating the constructor finished ok and the parameters satisfy the class business terms?

A constructor has no return parameters, how do you check if it finished ok and in case it didn't, what do you do?

If you don't use an Initialize method, can you think of a nice way to handle success or failure of such class initiailization?

thx (:
whroeder1
14470
whroeder1 2015.04.18 18:17  
In C++ you'd throw an exception, can't in Mt4. Either save a status and return it in a IsValid method, or use SetUserError/ResetLastError - MQL4 Documentation
Amir Yacoby
1192
Amir Yacoby 2015.04.18 20:18  
Thanks WHRoeder, nice answer
To add comments, please log in or register