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 namespace std; and what is consists of?
What is the difference between while and do while loop?
What is stack unwinding?
Would you rather wait for quicksort, linear search, or bubble sort on a 200000 element array? (Or go to lunch...) a) Quicksort b) Linear Search c) Bubble Sort
What is the most useful programming language?
What is a class template?
What is pointer to member?
Should a constructor be public or private?
What are the various storage classes in C++?
What do you mean by global variables?
Does c++ have a hash table?
Name four predefined macros.
Do vectors start at 0?
Define the process of handling in case of destructor failure?
What does extern mean in a function declaration in c++?