Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

we all know about the function overloading concept used in
C++ and we all learnt abt that.... but that concept is
already came in C in a very smaller propotion ... my
question is IN WHICH CONCEPT THERE IS A USE OF FUNCTION
OVERLOADING IS USED in C language?????????????

Answer Posted / sandeep

Function Overloading or Polymorphic Behaviour for C
functions can be seen for those functions who accept
variable number of arguments.
They can take any number of arguments and any type of
arguments, its upon the programmer or the code inside it,
that decides what it wants those arguments to be , int ,
char ,float or something else..

ALthough it is not seperate function that runs for different
number and types of arguments, still for the user, a
function will be provided for different types of list of
input parameters, all being sent to the same ('name of the
')function..

#include <stdarg.h>
enum data_type{ TYPE_INT=0,TYPE_STRING=1};
int max( int num_of_arguments,...)
{
va_list arg_list;
va_start(arg_list, num_of_arguments);
data_type type=va_arg(arg_list,data_type);

if(type=TYPE_INT)
{
int max =0,i;
for(i = 2; i <= num_of_arguments; i++)
{
if((a = va_arg(arg_list, int)) > max)
max = a;
}
}
else
{
//do whaterver..
}
va_end(arg_list);

}

Is This Answer Correct ?    10 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is malloc memset faster than calloc?

1016


What is typedef?

1330


Explain about the functions strcat() and strcmp()?

990


Create a simple code fragment that will swap the values of two variables num1 and num2.

1237


What are volatile variables in c?

889


In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none

1159


What is the advantage of c?

1047


What is an lvalue?

1014


What are the differences between Structures and Arrays?

1130


What is the use of #include in c?

1036


What is break in c?

985


What is a MAC Address?

1005


What is void pointers in c?

958


Explain what is the difference between far and near ?

1048


What are the types of functions in c?

934