u

Wednesday 6 June 2012

C++ Program to implement Function Overloading

C++ Program to implement Function Overloading


#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
// declaration of overloaded functions
void rectangle(int,char);
void rectangle(int,int,char);
main()
{
clrscr();
rectangle(2,5,'@');
rectangle(1,'a');
rectangle(2,'b');
rectangle(3,'c');
rectangle(4,'d');
cout<<"Press any key to continue";
getch();
return 0;
}

void rectangle(int n,char ch)
{
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout<<ch;
}
cout<<endl;
}
}
void rectangle(int l,int b, char ch)
{
for(int m=0;m<l;m++)
{
for(int n=0;n<b;n++)
{
cout<<ch;
}
cout<<endl;
}
}

0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More