Most superficial. In C, when you define a struct:
struct x {
int member;
char member2;
};
To use that, you have to use struct x whatever
. If you want to use x
as a name by itself (without the struct
preceding it) you have to use a typedef
:
typedef struct x {
int member;
char member2;
} x;
In C++, however, the first (without the typedef
) has roughly the same effect as the second (both define x
so you can use it by itself, without struct
preceding it). In C++, a class
is essentially the same as a struct
, except that it defaults to private
instead of public
(for both members and inheritance).
The only place there's a difference is if there is no definition of the class
in scope at the point of the function declaration.