471,066 Members | 1,298 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

why is size of empty class is 1 byte

Hello All, I have one question in mind...when you derive an empty class
and see its size it comes 1 byte,can somebody tell me why.....Thanks in
advance.
Ajay

Aug 22 '06 #1
1 2381
In article <11**********************@75g2000cwc.googlegroups. com>,
Ajay <aj**********@gmail.comwrote:
>Hello All, I have one question in mind...when you derive an empty class
and see its size it comes 1 byte,can somebody tell me why.....Thanks in
advance.
Because zero sized objects are normally not allowed so it normally
gets 1, though it could be more, it's implementation defined.
When derived from, it's implementation defined as well whether
or not it take up any space in the derived class since the
derived class won't be zero sized and no user base members would be
used since they don't exist.
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port now in alpha!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Aug 22 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by pembed2003 | last post: by
4 posts views Thread by Sweety | last post: by
8 posts views Thread by ishekara | last post: by
6 posts views Thread by free2cric | last post: by
8 posts views Thread by ypjofficial | last post: by
2 posts views Thread by Harish | last post: by
1 post views Thread by Ajay | last post: by
7 posts views Thread by Ajay | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.