segfault at method invocation

Pages: 12
The number of behaviors right across the board doesn't really matter. Similarly the number of combinations works itself out to a large extent via the inheritance pathway.

You can have zillions of behaviors. At the moment you're only addressing speed. Maybe have a class called Travel_Mode - walk, slither, fly, ooze, loiter - and associate the speed with that. Walk, Slither etc might just be a string descriptor as you already have or it might encapsulate more

Duck's are Animal's
that have a
Mode of movement might be a way to organize a heirarchy. A type of Duck could be a FastDuck or a SlowDuck - which is more or less what you have.

The vector just stores Animals regardless of what type - as you have.

Sure, they can all make sounds, some even take a dump - it's up to you to add the attribute/method/property in the most suitable place. Sound and Digestion could be classes.

I've used your model which seems OK - all I've done is taken that and implemented it the way I would at first glance - put it down to diversity - there's more than one way ...

Topic archived. No new replies allowed.
Pages: 12