Hacker Rank solution for Accessing Inherited Functions In C++