What is size of a empty class?
Answers were Sorted based on User's Feedback
Answer / dips
it doesnot take memory just writing class in C++
means i want to say
class d{};
no memory allocation is done here
but is this a empty class?
| Is This Answer Correct ? | 13 Yes | 2 No |
Answer / 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 |
Answer / mashal
Size of an empty class is 1 byte. It is non zero to ensure that the two different objects will have different addresses.
| Is This Answer Correct ? | 0 Yes | 0 No |
There is a magic square matrix in such a way that sum of a column or a row are same like 3 5 2 4 3 3 3 2 5 sum of each column and row is 10. you have to check that matrix is magic matrix or not?
What is a storage class in C++
Using a smart pointer can we iterate through a container?
what is Loop function? What are different types of Loops?
Describe about storage allocation and scope of global, extern, static, local and register variables?
what is importance of data sturture in a programming language?
22 Answers L&T, TCS, Wipro,
Explain what data encapsulation is in c++?
What is a smart pointer?
How are pointers type-cast?
How do you remove an element from a set in c++?
What is c++ try block?
Which is the best c++ compiler?