At 07:40 2007-02-02, Brett W. McCoy wrote:
>On 2/2/07, Ray Devore <[EMAIL PROTECTED]> wrote:
>
> > I keep seeing two different ways to define a struct
> > (see below). What is the benefit of doing the typedef
> > over just defining the struct with a tag?  Is one more
> > efficient than the other?
> >
> > typedef struct
> > {
> >     int ivar;
> >     double dvar
> > } Tdstruct;
> >
> > vs
> >
> > struct Tagstruct
> > {
> >     int ivar;
> >     double dvar
> > };
>
>Syntactical sugar. I use the typedef so I can do:
>
>TdStruct someStruct (which looks more C++-ish also)
>
>instead of
>
>struct TagStruct someStruct;

you only have to do that in C (a language that hopefully is 
dying).  C++ doesn't need (nor want, from my point of view) the typedef.


>Other than that, there's really no reason to use one over the other.
>They compile the same way, but it does keep your code slightly less
>cluttered. :-)
>
>-- Brett
>------------------------------------------------------------
>"In the rhythm of music a secret is hidden;
>     If I were to divulge it, it would overturn the world."
>                -- Jelaleddin Rumi
>
>
>To unsubscribe, send a blank message to 
><mailto:[EMAIL PROTECTED]>.
>Yahoo! Groups Links
>
>
>

Victor A. Wagner Jr.      http://rudbek.com
The five most dangerous words in the English language:
               "There oughta be a law" 

Reply via email to