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
Can a varargs method be overloaded?
Which is better struts or spring?
Why do we use polymorphism in oops?
What is oops in simple words?
Explain virtual inheritance?
What are different oops concepts?
Why we use classes in oop?
What is encapsulation with real life example?
what are the realtime excercises in C++?
i got a backdoor offer in process global,Bangalore..Can i work with it?
What is a null tree?
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?
Can we have inheritance without polymorphism?
What are oops functions?
What is object and example?