Write a C++ program using function Overloading static/early binding
#include <iostream>
using namespace std;
class Distance
{
public:
float feet,inches;
public:
void read()
{
cout<<"\n enter the feet:"<<endl;
cin>>feet;
cout<<"\n enter inches:"<<endl;
cin>>inches;
}
void read(Distance ob1,Distance ob2)
{
feet=ob1.feet+ob2.feet;
inches=ob1.inches+ob2.inches;
cout<<"\n feets="<<feet;
cout<<"\n Inches="<<inches;
}
};
int main()
{
Distance ob1,ob2,ob3;
cout<<"---------"<<endl;
cout<<"\n Distance 1"<<endl;
cout<<"---------"<<endl;
ob1.read();
cout<<"---------"<<endl;
cout<<"\n Distance 2"<<endl;
cout<<"---------"<<endl;
ob2.read();
cout<<"---------"<<endl;
cout<<"Total distance:"<<endl;
cout<<"---------"<<endl;
ob3.read(ob1,ob2);
return 0;
}