![]() |
Output of program
Code: CPP
The output will be,- 8 1 Why?... In class B, 1 byte is as usual allocated for char 'b'. But in case of class A, 4 bytes for integer 'a' and next 4 bytes for char 'b'. This is because of packaging format. |
Re: Output of program
I didn't knew this. Its really kool so out of excitement I tried even the double one and it gave 16 and 1
|
Re: Output of program
Hmmm,
even the size of pointers can change. If you have double and char* still it will be (8 + 8 =)16. |
Re: Output of program
Quote:
|
Re: Output of program
Can somebody please tell me what exactly the rules of this packaging format are???
|
Re: Output of program
Quote:
e.g. Variable 1 mem [8 bytes] | | | | | | | | Variable 2 mem [4 bytes] | | | | Instead of 4 bytes it allocates 8 to keep the packaging format in good shape for second variable memory. If you go about by sequential memory segment then also allocating each variable memory of n [choosen as maximum] is easier and so it allocates 8 + 8 bytes instead of 8 + 4 bytes. |
Re: Output of program
Thanks Very Much Shabbir...
|
Re: Output of program
Quote:
|
Re: Output of program
Very useful piece of information Shabbir bhai.
|
| All times are GMT +5.5. The time now is 14:40. |