|
From: <or...@vp...> - 2004-01-31 00:53:17
|
Noorez Kassam wrote:
> what is the difference between these two
>=20
> typedef struct _Human
> {
> int height;
> }Human;
>=20
> struct Human
> {
> int height;
> };
>=20
>=20
> and in the first one, what does 'Human' mean at the end? In both struct=
s=20
> u can declare a Human type, even without the Human thing at the end in=20
> the first one
These are the remnants of the C world. The difference is only noticable=20
in C. With the second version in the C world you had to write this to=20
declare a variable (a Human struct):
struct Human MyHuman;
However, with the first one (as Human is a new type in this case), you=20
could write this:
Human MyHuman;
So in the C world, you spared the struct prefix at variable declaration,=20
and saved yourself a lot of typing.
In the C++ world, this is no longer relevant, as struct automatically=20
defines a new type (like class).
--
Greetings,
Bal=E1zs
|