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.
Well, the first and the main question here - where is polymorphism? The main() function doesn't use abstract class at all - it defines and solely uses LRUCache instance, while correct implementation would require a pointer to the base class to be used.
Second. We all have access to std::list<> which provides way better implementation of the linked list than custom made code in the Cache class.
So, I defined class LRUCache as standalone and used pair of standard STL containers to hold the cache and registry.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Abstract Classes - Polymorphism
You are viewing a single comment's thread. Return to all comments →
Well, the first and the main question here - where is polymorphism? The main() function doesn't use abstract class at all - it defines and solely uses LRUCache instance, while correct implementation would require a pointer to the base class to be used.
Second. We all have access to std::list<> which provides way better implementation of the linked list than custom made code in the Cache class.
So, I defined class LRUCache as standalone and used pair of standard STL containers to hold the cache and registry.