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
Somehow, the question of whether or not multi-purposing affects CPU code processing speed has gone completely unnoticed(2011.04.04 21:58).
If the question seems incorrect, silly, etc. - then write so.
Somehow, the question of whether or not multi-purposing affects CPU code processing speed has gone completely unnoticed(2011.04.04 21:58).
If the question seems incorrect, silly, etc. - just write it so.
The question is perfectly logical, the answer is no, it doesn't.
I got it! Well, you've given me a lot of encouragement! I'll be doubling the pleasure of stamping nested methods now :)
Urain, thanks for the example! While you have no programming experience, sometimes it is difficult to guess yourself to check and write correct code for it. And here everything is clear and understandable.
Question. Can an instance of a child class delete itself? In other words, will such a construct work?
The compiler doesn't complain about this construct.Question. Can an instance of a child class delete itself? In other words, will this construction work?
The compiler doesn't complain about this construct.If I understand it correctly, I don't like pointers (and I don't use them often, especially in MQL5), the child should look like this
Therefore, the application would look like this
PS
Is it a bug (or a feature of the compiler) that the compiler missed it?
Of course, we can assume that the descendant passed the class we need but the structures and functionality of the two classes might be very different. So what happens then?
C_A *pointer=new C_B;
And when using the initial code like this, a memory leak occurs at all, although all the compiler checks have been passed (and it hasn't even mentioned any possible problems)
Here is the result (I understand that the pointer object is not correctly deleted because of the memory leak):
If I understand it correctly, I don't like pointers (and I don't use them often, especially in MQL5), then the descendant should look like this
C_A *pointer=new C_B;
I got this idea from tetris, and it works just fine for me. Of course, it wouldn't be right to use this line outright, but it's very suitable for similar purposes to those solved in tetris.Somehow, the question of whether or not multi-purposing affects the speed of code processing by the processor(2011.04.04 21:58) is left completely unattended.
If the question seems incorrect, silly, etc. - just write it.
The answer to logic -- the simpler and more logical the primitives, the more efficient the optimizer will be.
The main thing is not to overdo it :)
Slightly modified the script code:
Outputs
Look. I declared void Del(C_A *p) method with modifier public in the parent class. So the child class has fully inherited this method. So I don't need to re-declare the same method in the child class. As for this idea, I got it from tetris and it worked out very well for me. Of course, it wouldn't be correct to use this string outright, but it's very suitable for similar purposes to those solved in tetris.
Even assuming void Del(C_A *p) in the ancestor is sufficient to delete any descendant pointer, I don't see the point in using
C_A *pointer=new C_B;
PS
The only place where I can imagine the need for such an approach is creating an array of miscellaneous objects that are descendants of the same class (alternatively, passing a parameter of the "base" class type into a function or procedure).