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


Please Help Members By Posting Answers For Below Questions

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

610


which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1?

724


What is a modifier in c++?

636


Why null pointer is used?

587


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?

566






What does it mean to declare a member function as virtual?

591


What is split a string in c++?

696


What is private public protected in c++?

557


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?

565


Can recursive program be written in C++?

637


What is endianness?

626


Evaluate !(1&&1||1&&0) a) Error b) False c) True

707


What are c++ data types?

646


daily Routine of father

917


What is the difference between public, private, and protected access?

622