0

What is the diffrence between this :

struct foo
{
   ......
};

and

typedef struct foo
{
   ......
};
Marox Tn
  • 142
  • 9
  • In this case, beyond the duplicate [**here**](http://stackoverflow.com/questions/1675351/typedef-struct-vs-struct-definitions), another difference is the second snippet wouldn't compile, as there is no alias name. – WhozCraig Oct 15 '14 at 17:27
  • 1
    This isn't really a duplicate of http://stackoverflow.com/questions/612328/difference-between-struct-and-typedef-struct-in-c -- `struct` declarations behave differently in C++ than in C. – Keith Thompson Oct 15 '14 at 17:44
  • 1
    A `struct` declaration defines a new structure type. A `typedef` declaration merely creates a new name for an existing type. The syntax permits you to combine them into a single declaration. – Keith Thompson Oct 15 '14 at 17:46
  • I've expanded on this in [this answer](http://stackoverflow.com/a/26389105/827263) that I just posted to [this question](http://stackoverflow.com/q/1675351/827263). – Keith Thompson Oct 15 '14 at 18:03

1 Answers1

0

First declares a structure tag foo while second define a structure type foo.

haccks
  • 104,019
  • 25
  • 176
  • 264