C++ language

Program Of Function Overloading
Previous Home Next
#include<stdio.h>
void myfunction(int a)
{
cout<<"a is "<<a;
//overload myfunction
void myfunction(int a, int b)
{
cout<<"a is"<<a;
cout<<"b is"<<b;
}
//overload myfunction again
void myfunction(int a, double b)
{
cout<<"a is"<<a;
cout<<"b is"<<b;
}
void main()
{
myfunction(12); //calls myfunction(int)
myfunction(10,34) //calls myfunction(int, int)
myfunction(67,123.45) //calls myfunction(int, double)
}

output:

a is 12
a is 10
b is 34
a is 67
b is 123.45
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: