source code name: funover3.cpp
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
class sumoop
{
public:
void sum(int a, int b)
{
int sint=a+b;
cout<<" \n sum of integer numbers "<< sint;
}
void sum(float a, float b)
{
float sflt=a+b;
cout<<" \n sum of floats numbers "<< sflt;
}
void sum(long a , long b)
{
long slng=a+b;
cout<<" \n sum of long numbers "<< slng;
}
};
void main()
{
clrscr();
cout<<"function overloading program ";
sumoop ob1;
ob1.sum(100,50);
ob1.sum(250l,300l);
ob1.sum(2.56f,3.84f);
getch();
}
output:
function overloading program
sum of integer numbers: 150
sum of long numbers: 550
sum of floats numbers:6.40
0 Comments
Post a Comment