add c++ implementation