c++ advanced programming exercise