Re: OOB or procedural

From: Richard Heathfield (dontmail_at_address.co.uk.invalid)
Date: 12/01/03


Date: Mon, 1 Dec 2003 19:54:10 +0000 (UTC)


[Sorry for late reply - wasn't following this thread closely]

Programmer Dude wrote:

>
> But, what if you do this in C:
>
> typedef struct { char s[128]; } short_string;
>
> typedef struct { char s[128]; int n; } numbered_string;
>
> There's two "classes" where one "inherits" from the former. But,
> I'm hazy on whether ANSI C will allow you to treat a numbered_string
> as a short_string (via a required cast). [Richard, et alii?] I do
> know it will work adequately on many platforms.

The two structs are of different types. How, precisely, were you planning to
pretend that a numbered_string is a short_string? It matters. (For example,
memcpy(&ss, &ns, sizeof ss) would be perfectly legal.)

I know this is only a minor part of your discussion, and you probably don't
care very much, but if you want a definitive answer, I suggest you ask a
more detailed question in an appropriate forum (in this case, comp.lang.c).
Oh, and I wouldn't use the word "inherit" in there if I were you. :-)

<snip>

-- 
Richard Heathfield : binary@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton