typedef is used to define new data type names to make a program more readable to the programmer. ... The main use for typedef seems to be defining structures. For example: typedef struct {int age; char *name} person; person people; Take care to note that person is now a type specifier and NOT a variable name.
What is typedef struct in C++?
typedef struct Foo { ... } ... declares an anonymous structure and creates a typedef for it. Thus, with this construct, it doesn't have a name in the tag namespace, only a name in the typedef namespace. This means it also cannot be forward-declared.
What is the difference between typedef and struct?
Basically struct is used to define a structure. Though there is one subtle difference that typedefs cannot be forward declared. ... So for the typedef option, you must include the file containing the typedef before it is used anywhere.