Headlines
Loading...
Write a C++ program to implement Function Overloading.

Write a C++ program to implement Function Overloading.

PROGRAM: c++ program 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<<"www.adkool.com.";
  cout<<"\n\tAddress of area(int)="<<(unsigned int)p1;
  cout<<"\n\tAddress of area(int,int)="<<(unsigned int)p2;
  cout<<" \n\tArea of square is ::"<<p1(20);
  cout<<" \n\tArea of rectangle is ::"<<p2(10,20);
        cout<<"www.adkool.com.";
  getch();
}

OUTPUT

Address of area(int)=657
Address of area(int,int)=673
Area of square is ::400
Area of rectangle is ::200

*** PLEASE checkout the Best deals from for top sites like Amazon, Flipkart etc ***