From: "Idries Hamadi" <[EMAIL PROTECTED]>

> > OO *design* is a far older concept than C++

I wasn't disagreeing with that. I was just saying you can't really write OOP
code in C. Technically, of course, you can write anything in anything (the
first C++ code was mechanically translated to C). But in practical terms, I
think you need language support for inheritance to do OOP (not OOD).

> typedef struct _DerivedObjecType
> {
> BaseObject baseObject;
> int m_derivedObjectMember;
> } DerivedObject;

> typedef struct tagObject
> {
> EObjectType m_myType;
> union
> {
> base BaseObject;
> derived DerivedObject;
> }
> } Object;

I have to admit--that's rather cute! Now, do you know anyone who ever
programmed like that? :) (Also, is it guaranteed to work?)

The other thing is that this trick doesn't support OOP well (and forget
about multiple inheritance, of course). It's quite straightforward to
implement polymorphism in C with function pointer tables, but how would you
easily (and buglessly) specify that you wanted to use one entry from
BaseObject and one from DerivedObject. You _could_ do it, but no one would
ever bother. Which is why you don't see OOP in C, and which is why when I
hear people say they program OOP in C, I think they're really talking about
structured programming, no globals, etc.

> > I know, because I tried--before I ever heard of OOP or C++. :)
> How did you try to write OOP code in C before you heard of OOP?     &8-|

I knew I wanted inheritance, but I didn't know that's what it was called, or
that it was a cornerstone of OOP.


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to