What is size of a empty class?
Answer Posted / shiv chidambar
size of empty class is 1 byte.
because to indicate class existance in memory 1 byte is
allocated to indicate that class is present.
if the class is empty then there should some kind of
mechanism to indicate or to show this class is present.
if memory (1 byte) not alloacted such a empty class then how
we know that class is present but in programme that class is
written? so for that 1 byte allocated to indicate class
existance.
this happens only for emty classes(Consider example of
tagging interface in java which is empty class).
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What programming language should I learn first?
Is c++ a good beginners programming language?
Can a class be static in c++?
How we can differentiate between a pre and post increment operators during overloading?
Name four predefined macros.
How do you declare A pointer to function which receives an int pointer and returns a float pointer
What is the sequence of destruction of local objects?
What is the exit function in c++?
Which programming language is best?
What do the keywords volatile and mean mutable?
What does the following do: for(;;) ; a) Illegal b) Loops forever c) Ignored by compiler...not illegal
Differentiate between the message and method in c++?
How to declare a pointer to an array of integers?
What is c strings syntax?
What are advantages of using friend classes?