D vs. placement new (for classes) aka why D needs .sizeof and
Forest Ray
disto at flying-guillotine.com
Thu Apr 12 19:09:16 PDT 2007
Thanks for get me thinking along that path, the size of a class can be found by using CLASS.classinfo.init.length
import std.stdio;
class foo {
int a = 1;
int b = 2;
int c = 3;
}
void main() {
writefln("size = ", foo.classinfo.init.length);
}
./xxx
size = 20
Frank Benoit (keinfarbton) Wrote:
>
> > well, i don't know about the size of the class, but it does not give the
> > size of the class /instance/.
>
> I was sure i had an example that shows it doesn't.
> But it seems I am wrong. Sorry about that. If i find it, I file a bug
> report.
>
> Frank
More information about the Digitalmars-d
mailing list