const int FEET_IN_YARDS = 3;
const int YARDS_IN_MILES = 1760;
class Distance
{
int feet;
int yards;
int miles;
public:
int FeetAre() const;
int YardsAre() const;
int MilesAre() const;
Distance AddDistance(Distance d) const;
Distance ConverFeet(int f);
Distance ConverYards(int y;
void PrintDistance();
};
distance.cpp
Distance Distance::AddDistance (Distance d) const
{
Distance total;
int f = feet + d.feet;
total.feet = f%3;
int y = yards + d.yards;
total.yards = y % YARDS_IN_MILES;
total.miles = miles + d.miles + (y / YARDS_IN_MILES;
return total;
}
Distance Distance::ConvertFeet(int conFeet)
(Distance d) const: Distance d declares a function parameter of type 'Distance' and name 'd' const means that the function doesn't modify the object you called it from