> if you insist on searching the minimum yourself, my suggestion would
be to
pass a std::vector<> to your function. your function can then easily
iterate through the vector and search the minimum.
But then you have to put stuff in an array. I think he's looking for
something you could call like:
min(x, y, z, 10, k, g.getValue());
The answer to this question is yes and no. I would suggest, as victor
did, writing just a series of overloaded functions min(a,b),
min(a,b,c), etc., possibly with each function referring to the last.
For instance:
template<typename T>
T min(T a, T b, T c, T d)
{
T maybeMin = min(a,b,c);
if(maybeMin < d)
return maybeMin;
else
return d;
}
Make it up to 8 arguments or whatever you need.
There was a proposal before the C++ standards committee for type-safe,
variable length function parameters to replace the '...' in functions
such as printf. If accepted, this would provide a nicer way of doing
this. However, it won't be for a while; it'd need to be accepted, added
to the next version of the standard in who-knows-when, then implemented
before you could use it, so it's still a number of years off.