Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Sugestions for runtime polymorphism Date: Wed, 14 Sep 2016 16:56:16 -0700 Organization: None to speak of Lines: 24 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="7230"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19LVmk99JJgY49uNZMY8+lU" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:sIldVPG+vD8z7PzUE72g+7wvQjk= sha1:hcmXUztUJopqjRnfpHolp53jzyM= Xref: csiph.com comp.lang.c:93503 BartC writes: > On 14/09/2016 21:27, Thiago Adams wrote: [...] >> typedef struct >> { >> ObjectType type; >> } Object; > > So, ObjectType is just an int. And you're creating an entire struct just > to store that int, which designates a kind of object I presume. And > you're calling that struct an Object, while is a little misleading as it > doesn't contain or point to any actual data of type 'type'. A small quibble that doesn't affect your argument: ObjectType (which was defined as an enumerated type) is an integer type, but it's not an int. It's compatible with (not identical with) *some* predefined integer type, but the choice is implementation-defined. (gcc, for example, makes it compatible with unsigned int.) -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"