I am writing a program that executes two operations on a structure distanceType which is compose of three integer members: feet, yards, and miles.The function convertYards takes a distance in yards that is greater than or equal to 1760 (because there are 1760 yards in a mile) and converts it to x miles, y yards, and z feet (i.e. distanceType). I'm having trouble with the function parameters. convertYards takes in one integer value and returns a distanceType. The problem is I am not sure how to define the function. Since it can accept either distance1 or distance2 (integer values), a small part of the code is below, the area with the "???" is what I am confused about.
struct distanceType
{
int miles;
int yards;
int feet;
}
distanceType convertYards(int ???) //Define convertYards
Any help is appreciated, thanks.
Yard,Mile, etc. classes that have an implicit conversion operator to one base unit that you use for functions. It's easy to combine that with C++11's user-defined literals to callfoo(5_miles)orfoo(20_yards).