A simulation code written in C++ for magnetohydrodynamic problems