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
How static variables and local variablesare similar and dissimilar?
How does a C++ structure differ from a C++ class?
Const char *p , char const *p What is the difference between the above two?
If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?
Discussion on error handling of C++ .
Where Malloc(), Calloc(), and realloc() does get memory?
What is the correct syntax for inheritance a) class aclass : public superclass b) class aclass inherit superclass c) class aclass <-superclass
How can you link a c program with a c function?
why is c++ called oops? Explain
Comment on assignment operator in c++.
Mention the ways in which parameterized can be invoked. Give an example of each.
Explain the use of virtual destructor?
What is #include math h in c++?
what are Access specifiers in C++ class? What are the types?
How to get the current position of the file pointer?