Dynamic Calculator version 2 (C++ version)