C++ code I wrote