Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7
Rudra Pratap Singh hi, 🍎 yes the size of empty class is 1 byte as because when any class is created without any data members and member functions it is called as empty class. When this empty class is accessed by making an run time dynamic entity then as their is nothing in the class the object state and behaviour and execution is tend to 0 or null but as because when every object is made memory is allocated to that object and which is equal to 1 byte as memory architecture is assign 1 byte to the any object first them varies according to the data type. 🍎 now if one more object is created of the same empty class then again same memory address is assigned then an single class has two object with same memory allocates in C++ that's why the empty class has 1 byte memory address allocation. https://stackoverflow.com/questions/2362097/why-is-the-size-of-an-empty-class-in-c-not-zero If any query ping me Have these 🍎 🍎 🍎 🍎 🍎 🍎
30th May 2019, 6:18 AM
DishaAhuja
DishaAhuja - avatar