I am writing a simplified game to learn how to get more experience in C ++, and I have an idea when I feel that polymorphism almost works, but not. In this game, it Partymoves rather linearly through a Map, but sometimes it can collide with Forkon the road. Plug (mainly) a std::vector<location*>. Initially, I was going to introduce into the function a Partysomething like the following:
if(!CurrLocation->fork_.empty())
else
(CurrLocation++)
But I was wondering if there could be several options for the following:
CurrLocation = CurrLocation->getNext();
With a fork actually derived from a location, and overloading some new feature getNext(). But in the latter case location(the low-level structure) should be the one that presents the message to the user instead of “transmitting this backup”, which I don’t feel is elegant as it connects locationup to UserInterface::*.
Your opinion?
source
share