Re: Adress of a struct vs address of its first field
From: Andrey Tarasevich (andreytarasevich_at_hotmail.com)
Date: 03/14/05
- Next message: Thomas Matthews: "Re: Read a binary file"
- Previous message: gouqizi.lvcha_at_gmail.com: "Re: RTTI"
- In reply to: Grumble: "Adress of a struct vs address of its first field"
- Next in thread: Grumble: "Re: Adress of a struct vs address of its first field"
- Reply: Grumble: "Re: Adress of a struct vs address of its first field"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Thomas Matthews: "Re: Read a binary file"
- Previous message: gouqizi.lvcha_at_gmail.com: "Re: RTTI"
- In reply to: Grumble: "Adress of a struct vs address of its first field"
- Next in thread: Grumble: "Re: Adress of a struct vs address of its first field"
- Reply: Grumble: "Re: Adress of a struct vs address of its first field"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|