#include <iostream>
using namespace std;
class Distance{
private:
int feet;
int inches;
public:
Distance(){}
Distance(int ft, int in): feet(ft), inches(in){}
void show(){
cout << feet << " feet and " << inches << " inches" << "\n";
}
Distance operator+=(const Distance& d){
this->feet = feet+d.feet;
this->inches = inches+d.inches;
return *this;
}
void getdata(int ft, int in){
feet = ft;
inches = in;
}
bool operator<(const Distance& d){
if(feet < d.feet) {
return true;
}
if(feet == d.feet && inches < d.inches) {
return true;
}
return false;
}
};
Comments
Leave a comment