Overload Function In cpp
PROGRAM:
#include<iostream>
using namespace std;
void sub(float i,float j){
cout<<"\nsub : "<<(i-j);
}
void sub(int i,int j){
cout<<"\nsub : "<<(i-j);
}
void add(int i,int j){
cout<<"\nadd :"<<(i+j);
}
void add(float i,float j){
cout<<"\nadd :"<<(i+j);
}
int main(){
int a,b,ad;
float x,y;
cout<<"integer value are : ";
cin>>a>>b;
cout<<"float value are : ";
cin>>x>>y;
add(a,b);
add(x,y);//!arguments have different data types
sub(a,b);
sub(x,y);//!!arguments have different data types
return 0;
}
Comments
Post a Comment