Re: union of pointers to structs

Discussion in 'C Programming' started by Michael Foukarakis, Jan 14, 2010.

  1. On Jan 13, 12:55 pm, Richard Heathfield <> wrote:
    > Paul wrote:
    > > Please could you offer some advice as to whether
    > > the following code is good or bad practice.

    >
    > > It seems a nice versatile way to create arrays of
    > > 'Item' that point to different types of 'Object'.

    >
    > It does, however, mean that you need to change your union definition
    > every time you add a new type. What's wrong with void *?
    >


    aka. the "Now it needs to be a submarine" problem.

    @OP: I'd personally prefer using a void* for doing the same thing, but
    your way gets the job done as well.
    Michael Foukarakis, Jan 14, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt Garman
    Replies:
    1
    Views:
    663
    Matt Garman
    Apr 25, 2004
  2. Peter Dunker

    union in struct without union name

    Peter Dunker, Apr 26, 2004, in forum: C Programming
    Replies:
    2
    Views:
    867
    Chris Torek
    Apr 26, 2004
  3. Paminu
    Replies:
    5
    Views:
    637
    Eric Sosman
    Oct 11, 2005
  4. Tim Rentsch

    Re: union of pointers to structs

    Tim Rentsch, Jan 13, 2010, in forum: C Programming
    Replies:
    1
    Views:
    722
    Tim Rentsch
    Jan 15, 2010
  5. Maciej Labanowicz

    [union] Pointers to inherited structs are valid ?

    Maciej Labanowicz, Jan 1, 2013, in forum: C Programming
    Replies:
    104
    Views:
    987
    Tim Rentsch
    Jan 25, 2013
Loading...

Share This Page