C++ code for study