@Jack Van Stone
Sure, this thread is getting a bit out of hand but eh, what the heck
Maps are essentially a bunch of pairs, a key and a value associated with the key. So the value associated with the key "good" is "bad", and so on.
In the code I wrote, I write out the pairs, "good" is paired with "bad" etc. Then, I iterate through all of my pairs. C++11 added this really nice functionality for going through different maps/arrays/strings/vectors, which I've used here. It's the
for(auto p : toReplace)
part and it's just taking one pair at a time from my map and putting it in the variable p. The first string of the two strings in this pair is in
p.first
.
So, "good" would be the first string in the pair, and that's the string we want to find and replace. We put that into the replaceWords function, do the same thing with
p.second
and voila. We process that pair, and move on to the next.
That's just a simple use case, they're really useful for loads of different things but it gets more in-depth and I don't want to confuse you too much.
There's more info here, along with some examples if you click around if you decide you do want to become more confused:
http://www.cplusplus.com/reference/map/map/