Calling for minimum among arrays

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.

Thanks
Dave
RTFM http://cplusplus.com/reference/algorithm/min/
You may use std::min_element instead.
If the compiler is conforming wrt variadic templates:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <type_traits>
#include <iostream>

template < typename A, typename B >
inline typename std::common_type<A,B>::type
minimum( const A& a, const B& b ) { return a > b ? b : a ; }

template < typename FIRST, typename... REST >
inline typename std::common_type<FIRST,REST...>::type
minimum( const FIRST& first, const REST&... rest )
{ return minimum( first, minimum(rest...) ) ; }

int main()
{
    std::cout << minimum( 'a', 45, 26.7, 1000L, 4.7f ) << '\n' ;
}

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.
Topic archived. No new replies allowed.