This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Inheriting from size 0 (or size 1) base class
- From: "Suto, Gyorgy" <gyorgy dot suto at intel dot com>
- To: "'gcc-help at gcc dot gnu dot org'" <gcc-help at gcc dot gnu dot org>
- Cc: "Suto, Gyorgy" <gyorgy dot suto at intel dot com>
- Date: Tue, 28 May 2002 17:03:00 -0700
- Subject: Inheriting from size 0 (or size 1) base class
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