All the details are provided here:
[url removed, login to view]
There was an error in the description of the find function for assignment 4 (part 6). The original specification stated that the function should have a single string parameter. It should also have a parameter of the vector <City> to be searched.
The paragraph discussing this should (and now does) read:
To find the city you should write a function that searches a vector of cities for a city. T he function should have two parameters, a string representing the name of the city and the vector of cities to be searched . The function should return the index of the city, or -1 if the search is unsuccessful.
A rather strange situation that may cause an error can occur when calculating the distance between two cities (actually the distance between a city and itself). This error occurs when the acos() function receives an input greater than 1 (which it should not do). Without going into the details of exactly what is going on (it's to do with double arithmetic) the acos() function may get inappropriate input when you calculate the distance between a city and itself . So for example, calculating the distance between Vancouver and Vancouver! In these cases the distance should (obviously) be 0.
The easiest way of avoiding this error is to recognize that you are calculating the distance between a city and itself and just setting this distance to be 0, without using the spherical law of cosines formula. The simplest place to handle this is in the distance method of the City class. You can check to see if the latitude and the longitude of the calling object are the same as the parameter's latitude and longitude and then return 0.