c++ advanced programming exercise no.3