I have seen this "style" of coding in many places and have yet figured out why someone would use one "style" versus the other. I the best of my knowledge they do the same thing, but then again, we can learn something new every day. Anybody have a logical explanation?
Style 1:
1 2 3 4 5 6 7
typedefstruct _structure
{
//data here
int a;
int b;
} structure;
Style 2:
1 2 3 4 5 6
typedefstruct structure
{
//data here
int a;
int b;
};
The "Style 1" is the recommended way. It declares a structure _structure and creates an alias structure for that enabling you to create objects without the struct keyword.
The "Style 2" also aims for the same. But it omits the alias name. It is not actually an error in a c++ compiler but you may get warings like the one below which is obtained from a vc++ 6 compiler.
warning C4091: 'typedef ' : ignored on left of 'struct structure' when no variable is declared
Even when you declare a structure without a typedef keyword, the vc++ compiler will let you create object without the "struct" keyword.