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
Here's another question, here's theWiki articleAbstract Class
I'm interested in a C++ example
The result of the program:
Program:
This object of the class CB; call function cb.Abstr(); call function cb.fun().
This object of the class CC; call function cc.Abstr(); call function cc.fun().
.
.
interested in void fun ( void ) method :
- why is there no virtual specifier ?
- if we add virtual, what will it change later on ?
why and what for, here is the code:
2020.05.28 14:41:20.294 tst (EURUSD,H1) void B::Task()
2020.05.28 14:41:20.298 tst (EURUSD,H1) void B::Task()
2020.05.28 14:41:20.298 tst (EURUSD,H1) void A::HighPriorityTask()
2020.05.28 14:41:20.298 tst (EURUSD,H1) void A::HighPriorityTask()
it works the way I want it to - I have a base class and inherit from it. But my descendants will need only one method and I want to call objects that have HighPriorityTask() method first and then Task() regardless of the sequence of declaration and initialization
all in one loop
is it possible to do this in a simple way?
and of course all in one cycle.
is it possible by simple means?
And why the fuck would it need to be done in one cycle?
And why is it also natural?
Naturally there will be at least two cycles.
And why the fuck should it be done in the same cycle?
And why is it also natural?
Naturally there will be at least two cycles.
OK, two cycles means two cycles, so no miracle ((
OK, 2 cycles means 2 cycles, so no miracle ((
You could try to get rid of loops altogether.
There are examples of how to print from 1 to 100 without loops and without recursion.
Maybe these examples will help, if it's even relevant ))
Here's another question, here's theWiki articleAbstract Class
I'm interested in a C++ example
The result of the program:
Program:
This object of the class CB; call function cb.Abstr(); call function cb.fun().
This object of the class CC; call function cc.Abstr(); call function cc.fun().
.
.
interested in void fun ( void ) method :
- why is there no virtual specifier ?
- if we add virtual, what will it change later on ?
why and what for, here is the code:
2020.05.28 14:41:20.294 tst (EURUSD,H1) void B::Task()
2020.05.28 14:41:20.298 tst (EURUSD,H1) void B::Task()
2020.05.28 14:41:20.298 tst (EURUSD,H1) void A::HighPriorityTask()
2020.05.28 14:41:20.298 tst (EURUSD,H1) void A::HighPriorityTask()
it works the way I want it to - I have a base class and inherit from it. But my descendants will need only one method and I want to call objects that have HighPriorityTask() method first and then Task() regardless of the sequence of declaration and initialization
all in one loop
is it possible to do this in a simple way?
1. If you declare a base class pointer and create a child object, then when calling methods via this same pointer of the base class:
a) virtual methods are called by the child class (via the virtual function table specially created for this purpose)
b) non-virtual methods are called by base class. Even if they are overridden in the child class.
2. If you want to have a single loop, then
a) Sort the object array by type.
b) For specific tasks, keep a separate array of pointers to objects that solve these tasks. I.e. all the objects that must callHighPriorityTask
should be stored in a separate array, which should be called first.
h.e. How could you imagine that in general, without sorting, half of all objects will be executed first, and then the rest? :) Well, if only to start a job queue.
But this is a creative question, you can come up with a lot of sophisticated ways to solve a penny problem))) The main thing is not to encroach on the laws of physics and all will be well)))
2. If you want to use the same loop, then
a) Sort the array of objects by type.
b) For specific tasks, keep separate array of pointers to objects which perform these tasks. I.e. all the objects that must callHighPriorityTask
should be stored in a separate array, which should be called first.
h.e. How could you imagine that in general, without sorting, half of objects will be executed first, and then the rest? :) Well, if only to start a job queue.
But this is a creative question, you can come up with a lot of sophisticated ways to solve a penny task))) The main thing is not to encroach on the laws of physics, and everything will be fine)))
I don't want to, I believe the compiler will optimize the empty methods.
1. If you declare a pointer of a base class and create a child object, then when calling methods via this very pointer of the base class
a) virtual methods are called by the child class (via the virtual function table specially created for this purpose)
b) non-virtual methods are called by base class. Even if they are overridden in the child class.
yeah, i don't remember that i just fixed the json libraryhttps://www.mql5.com/en/code/11134(i found it on a githab somewhere a bit fresher than the KB).
and there were compiler warnings
deprecated behavior, hidden method calling will be disabled in a future MQL compiler version
fixed by specifying a method in a class
this.JSONValue:: getLong(getValue(index),out);
Thanks, it's a pretty clear picture
definitely don't want to, I think the compiler will optimize empty methods
But calling an empty function is not likely to eat much anyway.
OK, 2 loops means 2 loops, so there will be no miracle ((
Why should I shove into one loop something which is logically done in two loops? Because there is no speed, no clarity and simplicity gain and the size of hard drives is measured not in megabytes long ago.
Why cram in one cycle what can be logically done in two? Because there is no gain in speed, clarity or simplicity, and the size of hard drives is not measured in megabytes.
I haven't even used them yet! ))))
just need to know the specifications to make something similar to normal method calls
Thank you. That explains it very well.
Virtual? Not necessarily.
I wish I could show you an example, the question arose because of the great choice of polymorphism means, either virtual or without it, or inherit or close this method in derived classes
You can try to get rid of loops altogether.
There are examples of how to print from 1 to 100 without loops and without recursion.
Maybe these examples will help, if it's even relevant ))
Why? Another pattern. The only thing that pattern adepts didn't recognize it, evidently it is not orthodox and canonical. Why not recursion? Also recursion, only not along, but across.