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 is the difference between the parameter to a template and the parameter to a function?
What are friend classes?
What do you know about near, far and huge pointer?
the maximum length of a character constant can be a) 2 b) 1 c) 8
What data encapsulation is in c++?
Does there exist any other function which can be used to convert an integer or a float to a string?
Distinguish between new and malloc and delete and free().
What is the best c++ book?
What is a node class in c++?
what are the characteristics of Class Members in C++?
What is function declaration in c++ with example?
How to allocate memory dynamically for a reference?
Can we make any program in c++ without using any header file and what is the shortest program in c++.
write a corrected statement in c++ so that the statement will work properly. x = y = z + 3a;
What is called array?