Ive seen some library functions that do it, but lets say...
How would you write a max() function that could take 2 or more parameters, without rewriting the function for 3 params, 4 params, 5 params, etc..?
This is a discussion on non static number of function parameters? within the C++ Programming forums, part of the General Programming Boards category; Ive seen some library functions that do it, but lets say... How would you write a max() function that could ...
Ive seen some library functions that do it, but lets say...
How would you write a max() function that could take 2 or more parameters, without rewriting the function for 3 params, 4 params, 5 params, etc..?
look up va_list for more on how to handle variable number of parametersCode:int max (int num_para, ... ) { // Stuff to do the compares for each item return the_value_of_the_max_item; }