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

what is graphics

2011


What is advantage of inheritance?

690


When not to use object oriented programming?

570


What are benefits of oop?

638


What is destructor oops?

622






Why is abstraction needed?

567


What is abstraction encapsulation?

657


What are the types of abstraction?

555


What is the real time example of encapsulation?

595


Why do pointers exist?

659


What does <> mean pseudocode?

622


Can static class have constructor?

585


What is balance factor?

587


Which method cannot be overridden?

578


Why we use classes in oop?

579