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

Why do we use class?

629


What is new keyword in oops?

587


What are the components of marker interface?

598


Write a program to implement OOPS concepts such as inheritance, polymorphism, friend function, operator overloading?

4234


What are the benefits of polymorphism?

616






What is difference between oop and pop?

609


What is an interface in oop?

591


What is abstraction and encapsulation?

565


What is class and object with example?

583


What is encapsulation c#?

598


What are the 3 principles of oop?

611


Can we define a class within the interface?

549


Why do we use class in oops?

550


What is static in oop?

585


Get me a number puzzle game-program

1690