Is the combination typedef struct used in C++? On MDSN I see stuctures under C++ code with typedef structs. I read that it was used in C to avoid typing struct everytime you needed to use a structure. E.g
I read that it was used in C to avoid typing struct everytime you needed to use a structure
This is correct. In C, structs exist in a separate namespace, so if you just declare a struct "normally" you must preface it with the struct keyword whenever you instantiate it.
typedefs, on the other hand, are not put in a separate namespace, so typedefing a struct brings it into the "normal" namespace allowing you to use the name without the struct prefix.
In C++, none of that applies because structs are put in the normal namespace. Doing a typedef struct becomes optional.
Also what does it mean when you add things after the struct definition like above such as HDITEM and *LPHDITEM?
Those are the types you're typedef'ing. Those are the names that are put in the "normal" namespace. The one before the struct definition is in the struct namespace.
Example (C code):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// here, 'A' is a struct name in struct namespace
// but 'B' is the struct typedef, so it exists in the normal namespace.
A a; // ERROR, 'A' undeclared
struct A aa; // OK
B b; // OK
struct B bb; // ERROR, redeclaring 'b' as a new struct (different from A)
The * name (LPHDITEM in your example) is another typedef, but for a pointer type:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// is the same as doing this:
typedefstruct Foo* PFoo;