access properties of child class in base class array
i want to access child class properties that only exist in the child class in an array of type base class
How do I cleanly keep track of the type of various objects implementing a common interface without reflection?
In my multiplayer game I have an inventory package that acts as a facade over a lower-level package. To abide by the Open-Closed Principle, I have a class for each inventory action, like PlaceAirplaneCommand
and TurboTerminalCommand
that extends the abstract InventoryItem
with abstract classes in between that group these commands together. I then polymorphically call use()
or lose()
on the InventoryItem
abstract class in my Inventory
class which is the public API for the higher-level packages.
How do I identify the type of object without reflection in a game inventory system?
In my multiplayer game I have an inventory package that acts as a facade over a lower-level package. To abide by the Open-Closed Principle, I have a class for each inventory action, like PlaceRouteCommand
and TurboTerminalCommand
that extends the abstract InventoryItem
with abstract classes in between that group these commands together. I then polymorphically call use()
or lose()
on the InventoryItem
abstract class in my Inventory
class which is the public API for the higher-level packages.
Does C++ support subtyping?
I know it might be a silly question to ask, but I didn’t quite get an a absolute clear answer on this matter, so I thought I’d put it here.
Java – Use polymorphism or bounded type parameters
Suppose I have this class hierarchy…
Clarification about Polymorphism / Inheritance
I am trying to better my understanding of polymorphism.
Clarification about Polymorphism / Inheritance
I am trying to better my understanding of polymorphism.
How would I handle a set of differing event classes with differing handler interfaces in a single event processor?
I’m working on an event processor framework for a simple game I’m writing, in which multiple types of events are handled in a loop. Since these events carry distinct pieces of data (i.e. one carries a player and position, another carries a message and timestamp), I ended up creating different classes for them (though they still all implement a common interface, which is currently a marker interface).
How would I handle a set of differing event classes with differing handler interfaces in a single event processor?
I’m working on an event processor framework for a simple game I’m writing, in which multiple types of events are handled in a loop. Since these events carry distinct pieces of data (i.e. one carries a player and position, another carries a message and timestamp), I ended up creating different classes for them (though they still all implement a common interface, which is currently a marker interface).
Does subtype polymorphism distinguish between inheriting behavior, or inheriting an interface?
To provide some context, I’ve seen some comments lately that equate inheriting behavior from a supertype, with inheriting a pure interface with no behavior. But there are pretty significant, and different, consequences to each.