Implementing some data structures in C++