Contacts programming challenge
The Trie approach might be overkill for this question.  I think that a plain (ordered) std::set (or std::multiset) would be adequate.  The set's lower_bound() member takes you directly to the first entry with the specified substring.  From there, we can either count linearly, or use lower_bound again with a new key created by adding 1 to the last character, then just return the iterator difference.
I'd certainly consider writing separate add() and find() functions instead of plonking all the code in that big if/else.  If nothing else, it makes the unit tests easier to write.