Empty Class Size

What is the size of an empty class?

Questions by MURALIR

Showing Answers 1 - 9 of 9 Answers

VENKATGOPU

  • Aug 21st, 2009
 

Empty class size is 1.

Example:
 
#include<iostream>
using namespace std;
class A
{
};
int main()
{
    cout<<sizeof(A)<<endl;
    system("pause");
    return 0;
}

Thanks & Regards
Venkat Gopu

  Was this answer useful?  Yes

cpfeed

  • Oct 29th, 2009
 

class A{
}

most of time sizeof(A) = 1, however, it is a small integer regarding to the complier.

  Was this answer useful?  Yes

deep

  • Oct 13th, 2011
 

What is the output for the below example?

Code
  1. #include iostream

  2. using namespace std;

  3. class A

  4. {

  5. };

  6. int main()

  7. {

  8. coutsizeof(A)endl;

  9. system(pause);

  10. return 0;

  11. }?

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions