Glad it is working. However, you should try to post these questions in the C++ forums, rather than the more general algorithms and data structures forum. Those are a little more high traffic (more eyeballs!) and people more likely to know how to fix syntax problems.
However! If you have questions about algorithms and data structures at a bit of a higher level, this is the right sub-forum.
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.