Here is a suggestion for the data members that the class City should maintain:
The member functions of the class City should consist of constructors along with a bunch of methods for answering a variety of queries. My suggestion is to get the default constructor City() to read from miles.dat and store information read from the file into the data members mentioned above. The methods that your class is required to support are as follows:
An important property that selectCities is required to have is that it selects only from those cities that are already selected. This allows us to use selectCities repeatedly to select a set of cities that satisfy several constraints For example, we could first call
selectCities("population", 100000, 500000)to select cities whose population is in the range 100000 to 500000. We could then call
selectCities("name", "R", "T")This latter call would select cities with names between "R" and "T" from only among those cities already selected, i.e., those that have population in the range 100000 to 500000. As a result, the set of cities selected at this point is all cities with names between "R" and "T," whose population is in the range 100000 to 500000. You should be able to see that by calling selectCities repeatedly, one can select a set of cities that satisfy several constraints, e.g., all cities in California whose names start with "S" and which have population more than 200,000.
Note that the 1-dimensional boolean array selectedCities mentioned in the data members is meant to keep track of the set of cities that are currently selected. Assume that initially no cities are selected. Whether selectAllCities should have a void return type or whether it should return the selected cities in some manner, is for you to decide.