Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to inherit from multiple class

Tags:

objective-c

Let's say i have a griffon object that needs to be part of the felidae and bird class.
How do i do it ?
I can only make it inherit from 1 class at a time...

like image 968
CiNN Avatar asked Sep 02 '09 03:09

CiNN


1 Answers

This may help...

Multiple inheritance

  • There is no innate multiple inheritance (of course some see this as a benefit). To get around it you can create a compound class, i.e. a class with instance variables that are ids of other objects. Instances can specifically redirect messages to any combination of the objects they are compounded of. (It isn't that much of a hassle and you have direct control over the inheritance logistics.) [Of course, this is not `getting around the problem of not having multiple inheritance', but just modeling your world slightly different in such a way that you don't need multiple inheritance.]

  • Protocols address the absence of multiple inheritance (MI) to some extent: Technically, protocols are equivalent to MI for purely "abstract" classes (see the answer on `Protocols' below).

  • [How does Delegation fit in here? Delegation is extending a class' functionality in a way anticipated by the designer of that class, without the need for subclassing. One can, of course, be the delegate of several objects of different classes. ]

-Taken from http://burks.brighton.ac.uk/burks/language/objc/dekorte/0_old/intro.htm

like image 110
Kelly Robins Avatar answered Sep 22 '22 08:09

Kelly Robins