struct MYSTRUCT
{
int a;
};
struct
{
int a;
} MYSTRUCT;
Thanks for any help - I've always assumed they are the same, but thought I'd check! [smile]
C++ Structures
Hiya,
I have a quick question I was hoping someone could answer - what's the difference between these two structure declarations?
The first defines a structure named MYSTRUCT.
The second defines a variable named MYSTRUCT of an unnamed structure type.
The second defines a variable named MYSTRUCT of an unnamed structure type.
Often in C you will see code like this:
This doesn't declare any variables, it just allows one to reference a structure without dealing with the structure "namespace".
Example:
Versus:
typedef struct Foo { int a;} Foo;
This doesn't declare any variables, it just allows one to reference a structure without dealing with the structure "namespace".
Example:
struct One { int a; };void frobnicate( struct One * );// void frobnicate( One * ); causes error
Versus:
typedef struct One { int a; } One;// void frobnicate( struct One * ); could still do thisvoid frobnicate( One * ); // easier to read
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement