Inheriting from size 0 (or size 1) base class

Suto, Gyorgy gyorgy.suto@intel.com
Tue May 28 17:03:00 GMT 2002


Hi,

I have the following classes:

class A{
  static int s;
};

class C : public A{
  int i;
};

class B{
};

class D : public B{
  int i;
};

sizeof(C) == 8
sizeof(D) == 8

even though I was expecting 4 for both of them.
I'm using 2.95.2.

Can somebody explain this? (I'm sure I'm not the first one to ask this
question.
I searched around but found no explanation)
Thanks,
Gyuszi



More information about the Gcc-help mailing list