473,396 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 2652
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: pembed2003 | last post by:
Hi all, If I have the following: class Foo{ void something(void){;} }; and then later I say: Foo f;
4
by: Sweety | last post by:
hello, why sizeof an empty class why 1 byte ? plz illustrate this ? bye
8
by: ishekara | last post by:
Hi all, An object of a class A which has no member variables and no member functions, still the size of the object is 1 byte, if there is a byte member variable then also the size of the object...
6
by: free2cric | last post by:
Hi, What will the syntax sound like for checking size of an empty class? what will be the size. Thanks, Cric
3
by: ThazKool | last post by:
Is there anyway to write a class or struct that has no storage. It only operates on a reference to an already existing type. This is actually an extension to another thread. The thread went a...
8
by: ypjofficial | last post by:
Hi all, In what way does the enumerated data type contibute to the size of a class if its part of that class? eg. #include <iostream.h> class one { public:
2
by: Harish | last post by:
This was an interview question: The size of an empty class is 1 byte. Why? Should it not be 4 bytes? Because an invisible pointer "this" is part of every class?
1
by: Ajay | last post by:
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
7
by: Ajay | last post by:
Hi all, Please tell me why empty class has one Byte Size. thanks in Advance.. Ajay
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.