Yashwant Pinge
Answered On : Aug 30th, 2006
This can be achieved by using template.
For ex. template T mul( T a, T b);

1 User has rated as useful.
Login to rate this answer.
satyam
Answered On : Dec 18th, 2006
To some extent this can be achieved by using default arguments for the func. But this also depends what all parameters you need to pass in different cases.
Login to rate this answer.
depends on the requirement. if you got fixed no of arguments like,
sum(int, int)
sum(float, float) .. go for Templates.
If you have variable arguments and you know the data types, then make use of va_list. ie variable argument list
define the function like, sum(int x, ... ) { //code }
In this you can call the function as, sum(1,2,3) or sum(1) etc...

1 User has rated as useful.
Login to rate this answer.