We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Key idea of the solution is the usage of "virtual". If you don't use it in the definition of get_price() function in the base class, then whenever you use a baseclass pointer and try to call the implementation of get_price() in a subclass, you can only get the implementation in the base class, which is a version without adding 100.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Hotel Prices
You are viewing a single comment's thread. Return to all comments →
Key idea of the solution is the usage of "virtual". If you don't use it in the definition of get_price() function in the base class, then whenever you use a baseclass pointer and try to call the implementation of get_price() in a subclass, you can only get the implementation in the base class, which is a version without adding 100.