Question: Add a method called GroupHeroes to the HeroesDB class. Declare your method in the HeroesDB.h file and define the method in the HeroesDB.cpp file. The

Add a method called GroupHeroes to the HeroesDB class. Declare your method in the HeroesDB.h file and define the method in the HeroesDB.cpp file. The method should add data to the _groupedHeroes map field of the class. Make sure to make the keys case insensitive (ignore the case).
The goal is to fill the _groupedHeroes map where the keys are the first letters of the heroes and the value for each key is a vector of the heroes whose names start with that letter. EX: for the key B, the value would contain a vector of all the heroes whose names start with B.
Loop over the heroes vector of the class.
Check if the first letter of each hero name is in the _groupedHeroes map (use the find method).
If the key is NOT found, then
create a new vector
add the hero to the vector
then add the vector to the map as the value for that initial letter.
If the letter is already in the map, then add the hero to the vector that is stored for that key.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!