class/struct question

This is a discussion on class/struct question within the C++ Programming forums, part of the General Programming Boards category; Hi, I just found something to confuse me and nothing that would explain it to me. Seems like I got ...

Originally posted by Salem > If I replaced the struct with a class, would it make any difference ?
The only difference - as far as I know - is that classes default to private, and structs default to public.

Since this struct begins with public:
Changing it to a class should have no effect.

A variable _AUTHENTICATE_MESSAGE, a type AUTHENTICATE_MESSAGE and a type PAUTHENTICATE_MESSAGE that is a pointer to an AUTHENTICATE_MESSAGE type?

Or maybe a type _AUTHENTICATE_MESSAGE, a variable AUTHENTICATE_MESSAGE and a pointer *PAUTHENTICATE_MESSAGE to a _AUTHENTICATE_MESSAGE type?

If I'd follow 7studs example, the second paragraph would be the correct one, but somehow I got the feeling that the first one is correct. Or neither of them ?

edit: ok, I think I got it:

- _AUTHENTICATE_MESSAGE is the tag which I could use to create a variable using the struct keyword.... obviously something from the past so I don't need that anymore in C++...
- AUTHENTICATE_MESSAGE is the type...
- *PAUTHENTICATE_MESSAGE a pointer to a variable of that type...
- there are no variables declared in that piece of code.

A variable _AUTHENTICATE_MESSAGE, a type AUTHENTICATE_MESSAGE and a type PAUTHENTICATE_MESSAGE that is a pointer to an AUTHENTICATE_MESSAGE type?

Or maybe a type _AUTHENTICATE_MESSAGE, a variable AUTHENTICATE_MESSAGE and a pointer *PAUTHENTICATE_MESSAGE to a _AUTHENTICATE_MESSAGE type?

If I'd follow 7studs example, the second paragraph would be the correct one, but somehow I got the feeling that the first one is correct. Or neither of them ?

edit: ok, I think I got it:

- _AUTHENTICATE_MESSAGE is the tag which I could use to create a variable using the struct keyword.... obviously something from the past so I don't need that anymore in C++...
- AUTHENTICATE_MESSAGE is the type...
- *PAUTHENTICATE_MESSAGE a pointer to a variable of that type...
- there are no variables declared in that piece of code.

It that correct now ?

_AUTHENTICATE_MESSAGE is the original name of the structure.
AUTHENTICATE_MESSAGE is a typedef for _AUTHENTICATE_MESSAGE.
PAUTHENTICATE_MESSAGE is a typedef for _AUTHENTICATE_MESSAGE *.

Just so you know, these typdef things can get very complicated. The basic idea of a typedef is simple, but I've never seen a tutorial anywhere or an explanation of how to figure out the complicated ones that are allowed. The one you listed was a fairly simple one, and I couldn't figure it out. I've seen much more complicated ones too.

Notice that the basic typedef for a struct ooks like this(which is different than declaring a type and a variable at the same time):