> I want to make a program with a max function taking any number of type double and returns the greatest of them
for a small number of arguments (upto about seven or so), you could use overloaded function names.
#include <iostream>
#include <algorithm>
template< typename T > inline
const T& max( const T& a, const T& b, const T& c )
{ return std::max( std::max(a,b), c ) ; }
template< typename T > inline
const T& max( const T& a, const T& b, const T& c, const T& d )
{ return std::max( std::max(a,b), std::max(c,d) ) ; }
template< typename T > inline
const T& max( const T& a, const T& b, const T& c,
const T& d, const T& e )
{ return std::max( std::max(a,b), max(c,d,e) ) ; }
template< typename T > inline
const T& max( const T& a, const T& b, const T& c,
const T& d, const T& e, const T& f )
{ return std::max( max(a,b,c), max(d,e,f) ) ; }
template< typename T > inline
const T& max( const T& a, const T& b, const T& c, const T& d,
const T& e, const T& f, const T& g )
{ return std::max( max(a,b,c,d), max(e,f,g) ) ; }
template< typename T > inline
const T& max( const T& a, const T& b, const T& c, const T& d,
const T& e, const T& f, const T& g, const T& h )
{ return std::max( max(a,b,c,d), max(e,f,g,h) ) ; }
int main()
{
std::cout << max( 12.3, 4.5, 67.8, 9.98, 76.5, 4.3, 2.1, 0.0 ) << '\n' ;
}