Added a C++ solution