cast array to structure
- From: "mr.sir bossman" <mrsirbossman@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 23 Jul 2005 15:15:02 -0700
template<typename type>
class CData
{
public:
DWORD a;
DWORD b;
DWORD c;
type* m_Data() { return (type*)(this + 1); }
};
Note: Used old school cast to make my code more readable.
DWORD Data[] = { 0, 0, 0, 0 };
CData<type>* nulldata = (CData<type>*)&data;
type *wti = (type*)(((BYTE*)&data) + sizeof(CData<type>));
Are these cast safe?
class CData
{
public:
DWORD a;
DWORD b;
BYTE* m_Data() { return (BYTE*)(this + 1); }
}
DWORD Data[] = { 0, 0, 0 };
CData* nulldata = (CData*)&data;
Do I avoid structure padding if I do this? Is structure padding even a issue?
.
- Follow-Ups:
- Re: cast array to structure
- From: Alexander Grigoriev
- Re: cast array to structure
- Prev by Date: Class templates and friend function templates
- Next by Date: Re: Class templates and friend function templates
- Previous by thread: Class templates and friend function templates
- Next by thread: Re: cast array to structure
- Index(es):