Create a map of <std::string, int> (your string and your frequency).
iterate over the your string. for each word you come across search your map for it.
1. If the string can not be found in your map, add it to you map and a set the frequency to one.
2. If the string can be found increment the corresponding frequency by one.