Submitted Questions

  • What is the Size of an Empty Class

    What is the logic behind size of an empty class = 1? (As per C++)Ex:class base {};main(){printf("Size of the Empty Class is: %dn", sizeof(base));}It gives output: Size of the Empty Class is: 1I have not got the reason / logic behind this.Can anyone help me?


    • Mar 11th, 2011

    The size of the empty class is i byte because empty class will provide the default constructor, default destructor, default copy constructor and default assigment operator. These function are called by the address of the pointer to functions, so the size of these address is 1 byte.