Errors, bugs, questions - page 1891
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
Sure.
Are you sure? Because dynamic_cast is most often used for bottom-up conversion, from parent to offspring.
Moreover, in MQL it perfectly casts from bottom to top, even when it shouldn't:
Take a look at the discussed MQL5 code fragment.
Yes, it should not work and it's already explained above, but not because bottom-up cast is impossible.
If we cast the pointer from top to bottom, i.e. to the parent, after which we pass the pointer to somewhere else in the scope, the fields of the descendant will be available there?
Yes, here is an example demonstrating your question:
and output:First, we check the unresolved cast from the bottom up and get NULL. This is correct.
Then we create a CLASS2 object, assign a reference to it to its parent class (here it's important to understand that dynamically the environment knows that CLASS2 object's original type is stored in its meta-information). Then (just your question) dynamically cast (with conversion right checking based on source object's metainformation) from reference CLASS1 to CLASS2.
We check the result of casting and write it into variable i = 1. Finally we output the value of i, referencing the originally created object.
Everything works correctly and according to the specification (including the dynamic_cast spec of C++ itself).
Are you sure? Because dynamic_cast is most often used for bottom-up conversion, from parent to offspring.
Moreover, in MQL it perfectly casts from bottom to top, even when it shouldn't:
Exactly:
Don't forget to update to the latest builds. I'm currently testing on 1598, which was recently posted as a zipped version in this thread, I think.
Don't forget to update to the latest builds.
Yes, the old build.
That's right, you can't drive from the bottom up, only from the top down. This is for safety's sake.
Yes, the old build.
You rub this one out, it's misleading and directly contradicts the functioning of dynamic_castAs part of the CLASS1 -> CLASS2 head-to-head casting example raised, you got it right. That's the kind of casting most of the time people have in their heads.
Also, it's the "you can't cast from bottom to top, only from top to bottom" that's at the heart of the dynamic_cast safety check.
Those who know what they are doing understand the essence of dynamic_casting.
Don't forget to update to the latest builds. I'm currently testing on 1598, which was recently posted as a zip in this thread I think.
What exe file does the compiler and executor sit in?
Right now MT4b1080 is running MEb1599. Please explain what metaeditor.exe and terminal.exe do.
What exe file does the compiler and executor sit in?
The MT4b1080 is now running MEb1599. Please explain what metaeditor.exe and terminal.exe do.
The compiler for both platforms is the same. It is in metaeditor.exe
And the executor, which checks the same dynamic_cast, in terminal.exe ?
Forum on trading, automated trading systems and trading strategy testing
Bugs, bugs, questions
fxsaber, 2017.05.11 13:26
Why EX5 such codeDoes it weigh 5kb?