473,503 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Size of an empty class why 1 byte ?

hello,
why sizeof an empty class why 1 byte ?

plz illustrate this ?
bye
Jul 22 '05 #1
4 4928
Sweety wrote:
why sizeof an empty class why 1 byte ?


Because if it weren't there would be no way to
distinguish between different objects in an array.

V
Jul 22 '05 #2
On 20 Aug 2004 12:56:34 -0700, sw************@yahoo.co.in (Sweety)
wrote:
hello,
why sizeof an empty class why 1 byte ?

plz illustrate this ?
bye


Everything must have a different address in memory, otherwise there
are big possibilities for confusion with pointers, references and
suchlike. Hence even an empty class takes up one byte so the next
thing you declare will have a different address.

rossum

--

The ultimate truth is that there is no Ultimate Truth
Jul 22 '05 #3
On 21 Aug 2004 01:00:41 GMT, da*********@aol.com (DaKoadMunky) wrote:
http://www.research.att.com/~bs/bs_f...l#sizeof-empty


[mode = modesty NOT]Nice to see that Bjarne agrees with me.[/mode]

rossum

--

The ultimate truth is that there is no Ultimate Truth
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
7194
by: pembed2003 | last post by:
Hi all, If I have the following: class Foo{ void something(void){;} }; and then later I say: Foo f;
8
3072
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
4868
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
1794
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...
1
6587
by: Taiwo | last post by:
I generated a Typed Dataset class including a base64Binary column. This column was specified as a .NET type of Byte() in the class that was auto-generated. I set the value of this property to New...
8
2173
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
2140
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
2660
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
4458
by: Ajay | last post by:
Hi all, Please tell me why empty class has one Byte Size. thanks in Advance.. Ajay
0
7199
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,...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1501
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.