typedef struct <-> struct
-
What's the difference between
typedef struct _MYSTRUCT { int nValue; DWORD dwValue2; }MYSTRUCT;
andstruct MYSTRUCT { int nValue; DWORD dwValue2; };
With each of them I can instantiate variables of type MYSTRUCT like:MYSTRUCT myStruct;
And I doesn't need the old C style:struct MYSTRUCT myStruct;
So why should I use typedef combined with struct. Are there any advantages or disadvantages. Thanks for any comment. Konrad -
What's the difference between
typedef struct _MYSTRUCT { int nValue; DWORD dwValue2; }MYSTRUCT;
andstruct MYSTRUCT { int nValue; DWORD dwValue2; };
With each of them I can instantiate variables of type MYSTRUCT like:MYSTRUCT myStruct;
And I doesn't need the old C style:struct MYSTRUCT myStruct;
So why should I use typedef combined with struct. Are there any advantages or disadvantages. Thanks for any comment. Konrad -
What's the difference between
typedef struct _MYSTRUCT { int nValue; DWORD dwValue2; }MYSTRUCT;
andstruct MYSTRUCT { int nValue; DWORD dwValue2; };
With each of them I can instantiate variables of type MYSTRUCT like:MYSTRUCT myStruct;
And I doesn't need the old C style:struct MYSTRUCT myStruct;
So why should I use typedef combined with struct. Are there any advantages or disadvantages. Thanks for any comment. KonradIn a good old C, you can use structures only with the keyword
struct
. In C++, the only advantage of usingtypedef
is, that you write the struct name with one word :). In your example,MYSTRUCT
is an alias tostruct _MYSTRUCT
. Robert-Antonio "Czech Railways discovered, that in case of disaster the most damaged wagons were the first and the last. So they decided to create trains without them."