|
-
September 1st, 2009, 04:14 AM
#6
Re: class size changes when inheriting abstract ones...
 Originally Posted by wolfulus
int _tmain(int argc, _TCHAR* argv[])
{
// why it displays 10 since I'm using pack() and 3 short vars? why not 6?
printf("sizeof(DefaultPacket) : %d\n", sizeof(DefaultPacket));
// 10 + dword = 14... but i was expecting 10, 4 bytes appeared from nowhere
printf("sizeof(MyAction1) : %d\n", sizeof(MyAction1));
You shouldn't need to know the sizeof() those classes. The classes you are using are non-POD. The size of a non-POD type is useless to you and what you're trying to do.
So trying to figure out what the sizeof() a non-POD type iis indicates you're program is doing something incorrect in terms of design and approach. The one reason to try and figure out the sizeof() a non-POD type is to use placement-new or equivalent, and your program is not doing that.
So you need to go back to the beginning and come up with a different strategy altogether. The sizeof() approach isn't going to work.
Regards,
Paul McKenzie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|