Added C++ implementation