Question 5_1 c++ implementation