July 2019
Intermediate to advanced
416 pages
10h 6m
English
A situation that often comes up is needing to store a number of items with an easily looked up key. For instance, suppose we had a music collection broken down into a number of genres:
enum Genre { Rock, CountryAndWestern, Classical, Pop, HeavyMetal}
Against each one of these genres, we are going to store the details of a number of artists or composers. One approach we could take would be to create a class that represents each genre. While we could do that, it would be a waste of our coding time. The way we are going to solve this problem is by using something called a map. A map is a generic class that takes in two types: the type of key to use for the map and the type of objects to store in it.
The key is a unique ...
Read now
Unlock full access