Path: utzoo!attcan!uunet!mcsun!hp4nl!botter!star.cs.vu.nl!jos From: jos@cs.vu.nl (Jos Warmer) Newsgroups: comp.sw.components Subject: Re: Inheritance vs. component efficienc Message-ID: <3053@vlot.cs.vu.nl> Date: 24 Aug 89 06:53:35 GMT References: <5682@hubcap.clemson.edu> <130200005@p.cs.uiuc.edu> <1233@ttds.UUCP> Organization: V.U. Informatica, Amsterdam, the Netherlands Lines: 43 jonasn@ttds.UUCP (Jonas Nygren) writes: >In article <130200005@p.cs.uiuc.edu> johnson@p.cs.uiuc.edu writes: >> 2) For some reason, run-time binding is necessary. >If C is to be considered a conventional language then there is a way to avoid >the case-construct. Just declare a structure as follows: > typedef struct{ > .... > void (*display)(); > } window; >and then the following code would achieve what Ralph wants: > window a, b; > a.display = draw_small_window; > b.display = draw_big_window; The previous two lines are just run-time binding done by hand. > (*a.display)(a); > (*b.display)(b); >without case-constructs. >It's even possible to achieve single-inheritance by adding the derived >class's members after the base-class members in a new struct, and this >could be semi-automated by nested include-files. This is just inheritance done by hand. Conclusion: Run-time binding still seems neccesary. OO languages offer this support automatically. In C you can do-it-yourself, although it looks very cumbersome to me. Jos Warmer jos@cs.vu.nl ...uunet!mcvax!cs.vu.nl!jos --