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
Which of the following is not a valid declaration for main() a) int main() b) int main(int argc, char *argv[]) c) They both work
which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1?
What is a modifier in c++?
Why null pointer is used?
How can you quickly find the number of elements stored in a dynamic array? Why is it difficult to store linked list in an array?
What does it mean to declare a member function as virtual?
What is split a string in c++?
What is private public protected in c++?
Can you be bale to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?
Can recursive program be written in C++?
What is endianness?
Evaluate !(1&&1||1&&0) a) Error b) False c) True
What are c++ data types?
daily Routine of father
What is the difference between public, private, and protected access?