For example, I have a class
,
class naive {
public:
char a;
long long b;
char c;
int d;
};
and according to my testing program, a
to d
are built one after another, like
a-------
bbbbbbbb
c---dddd
-
means unused.
Why does not C++ make it tighter, like
ac--dddd
bbbbbbbb
bbbbbbbbddddac
would be even tighter and you don't have to pad 2 bytes behind – Lieutenancy