I am trying to check the size of a class. Also, I am new to C++. I have two classes, the difference between two classes is just that one has 8 methods in it. How come there is no difference in size of class in both of it. Can you please explain me with the concepts?
#include <iostream>
using namespace std;
class A
{
int b;
char c[2];
int func(int x, int y)
{
return x+y;
}
int func1(int x, int y)
{
return x+y;
}
int func2(int x, int y)
{
return x+y;
}
int func3(int x, int y)
{
return x+y;
}
int func4(int x, int y)
{
return x+y;
}
int func5(int x, int y)
{
return x+y;
}
int func6(int x, int y)
{
return x+y;
}
int func7(int x, int y)
{
return x+y;
}
};
class B
{
int b;
char c[2];
};
int main()
{
cout<<"Size of class A is "<< sizeof(A)<<endl;
cout<<"Size of class B is "<< sizeof(B)<<endl;
return 0;
}
The output is the following -
$ ./class_size.out
Size of class A is 8
Size of class B is 8