adding c++ implementation