You cannot compare a struct to NULL.
You would need a comparison struct element as replacement of NULL.
Since you are using a constructor in the struct, you could replace NULL with a local struct variable, representing an empty element to be compared to your array element.
Thank you very much. I'll try your suggestion.
Did you try overloading the == operator?
bool operator== (const SStruct &op) { return this.mInt==op.mInt && this.mString==op.mString; } bool operator!= (const SStruct &op) { return this.mInt!=op.mInt || this.mString!=op.mString; } bool operator== (int i) { return this.mInt==i; } // ==NULL goes here bool operator!= (int i) { return this.mInt!=i; } // !=NULL goes here
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
Hi! I'm pretty new to programming and trying out the following code. It works for an int array but not on struct array. Maybe it will work if I check for the specific member of the struct like a[iLast].mInt != NULL on the check at the Add1DArrElem (the line with comment // illegal operation error here) function definition but then the whole function will be specific to this struct definition. I wanted to create a function I could reuse on other arrays of any type including struct. Is there already a library predefined with such functions (for mql4)? Or is there a better way of doing this altogether?