LogFAQs > #908335876

LurkerFAQs, Active DB, DB1, DB2, DB3, Database 4 ( 07.23.2018-12.31.2018 ), DB5, DB6, DB7, DB8, DB9, DB10, DB11, DB12, Clear
Topic List
Page List: 1
TopicAnother 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