- Exercises
Explore exercises that deepen your understanding of C++ literals by extending the MyDistance class to include feet and miles units. Learn to implement calculations combining multiple distances in meters and kilometers, enhancing your practical skills with user-defined types.
We'll cover the following...
We'll cover the following...
Exercise 1 #
Extend the MyDistance class we saw in the previous lesson to support the following units:
-
Feet: 1 ft = 0.3048m
-
Mile: 1 mi = 1609.344m
Choose good suffixes for these units.
Write an implementation below:
Exercise 2
The total distance of someone’s weekly drive consists of many components. Extend MyDistance so that we can calculate the total distance based on the following formula:
...