Below are two structures defined in C/C++:
struct a
{
static int i;
void fun() {int i;}
};
struct b
{
static int i;
};
a obj1;
b obj2;
why sizeof of both obj1 and obj2 are same?
Below are two structures defined in C/C++:
struct a
{
static int i;
void fun() {int i;}
};
struct b
{
static int i;
};
a obj1;
b obj2;
why sizeof of both obj1 and obj2 are same?
Non-virtual member functions and static members don't affect the size of an object, as they aren't stored inside the object.
Adding one or more virtual member functions would increase the size by an implementation-specific amount, usually the size of a pointer.