Function overloading
narendra
c_cpp
10 months ago
522 B
4
Indexable
#include <iostream>
using namespace std;
class Sum {
public:
void add (int x, int y){
int sum = x + y ;
cout<<sum<<endl;
}
void add (int x , int y , int z){
int sum= x+y+z;
cout<<sum<<endl;
}
void add (float x , float y){
float sum = x+y;
cout<<sum<<endl;
}
};
int main (){
Sum s;
s.add(2,4);
s.add(3,6,6);
s.add(float(2.5), float(2.5));
return 0;
};Editor is loading...
Leave a Comment