With b1650 works without problems. I don't know what changes they made in last builds but some things didn't work before now works well
Here is what I use for pointers. It's a small modification of CArrayObj which allows you to use the [] operator on the array of objects. Here is an example.
#include <Arrays\objvector.mqh> class MyClass : public CObject { protected: int m_index; public: MyClass(int index):m_index(index){} MyClass* Print() {::Print ("index = "+string(m_index));return &this;} MyClass* Alert() {::Alert ("index = "+string(m_index));return &this;} MyClass* Comment(){::Comment ("index = "+string(m_index));return &this;} }; void OnStart() { objvector<MyClass*> src_arr, dst_arr; for(int i=0;i<5;i++) src_arr.Add(new MyClass(i)); dst_arr.AssignArray(&src_arr); for(int i=0;i<dst_arr.Total();i++) dst_arr[i].Print().Alert().Comment(); } //+------------------------------------------------------------------+Just remember if you use CArrayObj that it manages memory by default so as soon as the objvector gets destroyed it also destroys all objects it points to. To turn off the memory mgmt you want to use
src_arr.Freemode(false);
Files:
objvector.mqh
1 kb
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
Hello,
I want to use ArrayCopy() on an array of pointers but it looks like i'm not allowed. It generates an error saying that array cannot contain objects. Is it not possible to use ArrayCopy() with arrays containing object pointers?
Docs say "Array of classes and structures containing objects that require initialization aren't copied". But nothing about pointers.
thnx.