C++ code added and documented