pass a array reference to a function and assign it to a value New comment [Deleted] 2017.10.12 14:51 Hey all,could please someone help me ? Guess i didn't got the concept completly.I have a class which should handle my buffer data. I want to pass a array to this class and set the pointer to a internal variable.Like this:// add a object to listclass1 object = new class1;// create a arraydouble arrayRef[];// pass arrayobject.setArrayRef (arrayRef);The class looks like this:class class1 {public: void class1() {}; void ~class1() {}; // var & functions double buffer[]; double setArrayRef (double &arrayRef[]); };double class1::setArrayRef (double &arrayRef[]) { my_buf.buffer = arrayRef;}When i do this, i get the error message:'buffer' - invalid array access array_struct_ref_simple.mq5 Do i do something wrong or do i think on the wrong way ? Passing a array ref and work with the is fine, but this not.My idea was like, setting once the pointer and having functions like getGreatestValue(), sortValues() etc ...which can work with the pointer.Thanks Errors, bugs, questions New MetaTrader 4 Platform build 1045 Suggestions For MQL5's Lack Of Support for Array Pointers? Stanislav Korotky 2017.10.12 15:12 #1 You can't do this in MQL. Instead you can wrap your buffer into an object and pass/assign a pointer to the object. [Deleted] 2017.10.12 16:03 #2 yeah....thank you ! it works. Was a bit recoding but now it works like expected. I still have to get into the language.Have a nice day ! New comment
Hey all,
could please someone help me ? Guess i didn't got the concept completly.
I have a class which should handle my buffer data. I want to pass a array to this class and set the pointer to a internal variable.
Like this:
// add a object to list
class1 object = new class1;
// create a array
double arrayRef[];
// pass array
object.setArrayRef (arrayRef);
The class looks like this:
class class1 {
public:
void class1() {};
void ~class1() {};
// var & functions
double buffer[];
double setArrayRef (double &arrayRef[]);
};
double class1::setArrayRef (double &arrayRef[]) {
my_buf.buffer = arrayRef;
}
When i do this, i get the error message:
'buffer' - invalid array access array_struct_ref_simple.mq5
Do i do something wrong or do i think on the wrong way ? Passing a array ref and work with the is fine, but this not.
My idea was like, setting once the pointer and having functions like getGreatestValue(), sortValues() etc ...which can work with the pointer.
Thanks