This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]