Please give an example of the use of this construction.
Please give an example of how to use this construct.
The most trivial example is an array class. In this case it is used to store any pointers:
template<typename T> class CArray { T _data[]; public: T operator[](int i) const { return _data[i]; } int Size() const { return ArraySize(_data); } // и т.д. }; СArray<void*> pointers;
The most trivial example is the array class. In this case it is used to store any pointers.
How to use it then?
class A { public: void OnInit() { Print(__FUNCSIG__); } }; class B { public: void OnInit() { Print(__FUNCSIG__); } }; void OnStart() { void* Pointers[2]; A a; B b; Pointers[0] = &a; Pointers[1] = &b; for (int i = 0; i < ArraySize(Pointers); i++) Pointers[i].OnInit(); // 'OnInit' - member function not defined }
Cast to the type you put there originally (or check via dynamic_cast).
// (A*)Pointers[i].OnInit(); ((A*)Pointers[i]).OnInit();
This is just on the subject of whether brackets are necessary/unnecessary... With this casting it would be a bummer in the script above when executed. I.e. you need to know the names of the classes that the array pointer elements refer to.
I don't see what the convenience is then.
MQ only uses void* in one place.
typedef string(*DoubleToStringFunction)(double,void*);
MQ only uses void* in one place.
Because they have everything built on CObject, it makes it impossible to use their containers for their own classes and interfaces, not inherited from their class. I.e. not a universal solution.
This is probably due to the fact that at the time of creation of their library there wasn't void* in MQL yet. But on the other hand their object itself also takes part in some manipulations (changing values of pointers in it), which in itself is just wild.
This makes it impossible to use their containers for their own classes and interfaces not inherited from their class, i.e. not a universal solution.
Perhaps this is because at the time their library was created, there was no void* in MQL yet.
Unfortunately, I haven't seen an example of its use.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Compiler error. Bild 1961, 64 bit.