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...

write a program for function overloading?

Answer Posted / abhishek.karal

Program illustrating function overloading

# include<iostream.h>
# include<conio.h>
int area(int side)
{
return side*side;
}
int area(int l , int b)
{
return l*b;
}

void main()
{
clrscr();
int (*p1)(int);
int (*p2)(int,int);

p1=area;
p2=area;

cout<<"Address of area(int)="<<(unsigned int)p1<<endl;
cout<<"Address of area(int,int)="<<(unsigned int)p2<<endl;

cout<<"Invoking area(int) via p1 "<<p1(20)<<endl;
cout<<"Invoking area(int,int) via p2 "<<p2(10,20);
getch();
}

Is This Answer Correct ?    57 Yes 23 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a varargs method be overloaded?

1093


Which is better struts or spring?

1050


Why do we use polymorphism in oops?

1031


What is oops in simple words?

1083


Explain virtual inheritance?

1188


What are different oops concepts?

1057


Why we use classes in oop?

1032


What is encapsulation with real life example?

1032


what are the realtime excercises in C++?

2832


i got a backdoor offer in process global,Bangalore..Can i work with it?

2837


What is a null tree?

1133


INSTANCE FIELDS DECLARED private ARE ACCESSIBLE BY THE METHODS ONLY.CAN WE CHANGE THE private FIELD OF AN OBJECT IN A METHOD OF SOME OTHER OBJECT OF THE SAME CLASS?

2200


Can we have inheritance without polymorphism?

1019


What are oops functions?

1009


What is object and example?

1168