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
Explain about Virtual Function in C++?
Define 'std'.
Describe private, protected and public – the differences and give examples.
How does class accomplish data hiding in c++?
How do I exit turbo c++?
In what situations do you have to use initialization list rather than assignment in constructors?
What is prototype for that c string function?
Do you know about C++ 11 standard?
Why do we use classes in c++?
Explain the use of virtual destructor?
How can you quickly find the number of elements stored in a a) static array b) dynamic array ? Why is it difficult to store linked list in an array?how can you find the nodes with repetetive data in a linked list?
What is an iterator?
Which is better c++ or java?
Define the process of error-handling in case of constructor failure?
What is wrapper class in c++?