Topic List | Page List: 1 |
---|---|
Topic | Another programming question |
Yellow 09/08/18 5:21:29 AM #1: | In my game engine, I've got a class hierarchy. This is my first time using class inheritance. I've got abstract WorldObject -> abstract AnimatedObject -> abstract PhysicsObject -> Creature I don't think I like this too much... but I do see the point. The child class can access the position of the WorldObject, and they have access to every other inherited function. I do feel I could do most of this system by turning them into standalone objects, though, instead having class Creature { WorldObject world_object; AnimatedObject animated_object; PhysicsObject physics_object; } At the same time, I hear there's something called an "Interface" I could be using that I still don't know about. Anyway, my question. AnimatedObject : WorldObject { // has a public virtual void Update(float step) // function.} PhysicsObject : AnimatedObject { // has a public override void Update(float step) // function.} The problem is, I want Creature : PhysicsObject { // to have a public override void Update(float step) // function as well.} Preferably I'd be able to call the base Update() function for each and every Update() function the child inherits. Googling got me nowhere, so here I am. ... Copied to Clipboard! |
Topic List | Page List: 1 |