Daniel Cioca: Is not working on struct arrays. How can i search for a value in a array of a struct ?
You can't search a struct for value. A struct is not a value.
You could search all structs for a member value, e.g. if(array[i].orderticket == value).
Or create your search criteria and use it.
template<typename T, typename UnaryPredicate> int ArraSearch(const T &array[], UnaryPredicate& pred) { for(int i=0;i<ArraySize(array);i++) if( pred.isMember(array[i]) ) return i; return EMPTY_VALUE; } class byTicket{ int t; public: byTicket(int ticket) : t(ticket){} bool isMember(const exmpl& e){ return e.orderTicket == t; } }; byTicket byT(ticket); int i = arraSearch(arr, byT);
William Roeder #:
You can't search a struct for value. A struct is not a value.
You could search all structs for a member value, e.g. if(array[i].orderticket == value).
Or create your search criteria and use it.
Thank you.
template<typename T, typename UnaryPredicate> int ArraSearch(const T &array[], UnaryPredicate& pred) { for(int i=0;i<ArraySize(array);i++) if( pred.isMember(array[i]) ) return i;
Apologies, I dont understand this
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! So I have this array of a struct:
And i have this function that i use for searching . Is not working on struct arrays. How can i search for a value in a array of a struct ? thanks