The class Distance is defined below:
class Distance //English Distance class
{
private:
int feet;
float inches;
public: //constructor (no args)
Distance() : feet(0), inches(0.0)
{ } //constructor (two args)
Distance(int ft, float in) : feet(ft), inches(in)
{ }
};
Overloading the following operators:
a. + to add two Distance objects using member function.
b. - to subtract two Distance objects using friend function
c. << and >>
Use the following main function to test your class Distance.
int main()
{
Distance dist1, dist3, dist4; //define distances
cin>>dist1;
Distance dist2(11, 6.25); //define, initialize dist2
dist3 = dist1 + dist2; //single '+' operator
dist4 = dist1 - dist2; //friend '-' operators
//display all lengths
cout << \"dist1 = \";
cout<< dist1 << endl;
cout << \"dist2 = \";
cout<< dist2 << endl;
cout << \"dist3 = \";
cout<< dist3 << endl;
cout << \"dist4 = \";
cout<< dist4 << endl;
return 0;
}
PLEASE DO THIS WITH C++
Also, using declaration of array and using [] notationfor accessing element of array