Hey guys, I have a program where I need to call for a minimum for each value of an array. I have no problems finding the minimum when I call for it among 2 of them, like this:
cout << " Min: " << min(Vendor1[ix], Vendor2[ix]) <<endl;
but when I ask for min among 3, like this:
cout << " Min: " << min(Vendor1[ix], Vendor2[ix], Vendor3[ix]) <<endl;
I get an error saying:
"Lab 8 J Grasp.cpp:76: instantiated from here
stl_algobase.h:99: `comp' cannot be used as a function"
And Im not sure at all what the error means.
Any help would be greatly appreciated.
Thank you both.
I have it with the way JLBorges showed it.
I understand how min_element works after reading through your link ne555 but it had something wrong with it in my program. Ill have to come back to it and figure it out!
Thanks again guys,
Dave
> I understand how min_element works ... but it had something wrong with it in my program.
std::min_element() finds the smallest element in a sequence where the range is provided by a pair of iterators.
It is unusable for your specific requirement which is:
find the minimum of three values (Vendor1[ix], Vendor2[ix], Vendor3[ix]) which are not in the same sequence.