C++ code implementations