added c++ solution to problem #6