C++ implementation of trie