Re: Adress of a struct vs address of its first field

From: Andrey Tarasevich (andreytarasevich_at_hotmail.com)
Date: 03/14/05


Date: Mon, 14 Mar 2005 12:58:51 -0800

Grumble wrote:
> ...
> Assume I have a plain, old, boring struct foo (i.e. no virtual
> functions, no methods, just data fields). Assume the first field is bar.
>
> struct foo s;
>
> Will &s == &(s.bar) always be true regardless of the type of bar?

Yes, for POD structs. You just have to convert the pointer types
accordingly (using 'reinterpret_cast').

> What if the type of bar is unsigned char[16]?

Doesn't matter.

-- 
Best regards,
Andrey Tarasevich


Relevant Pages