--- peternilsson42 <[EMAIL PROTECTED]> wrote:
> "Shyan Lam" <[EMAIL PROTECTED]> wrote:
> > Ray Devore <rbdevore2007@> 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?
> >
> > In C language prior to C99, the struct tag alone
> cannot
> > be used to declare an object of struct type:
> >
> > struct MY_STRUCT
> > {
> > ...
> > };
> >
> > MY_STRUCT myObj; /* Error in C90 */
>
> It is still an error in C99.
>
> > In C++, the tag name can be used as a type without
> the
> > 'struct' keyword:
>
> True.
>
> <snip>
> > C99 follow suit and adapted this syntax.
>
> Technically, it's valid syntax in that it follows
> the grammar,
> however it is (still) not semantically valid. Struct
> tags
> remain in a separate name space in C.
>
> --
> Peter
>
Thanks for the replies. I have been doing C++ and
classes and haven't been working with structs and C
for a while. So basically the typedef keeps you from
typing struct when you define an instance of the
struct.
Ray
____________________________________________________________________________________
TV dinner still cooling?
Check out "Tonight's Picks" on Yahoo! TV.
http://tv.yahoo.com/