d/copyconstructor/copyconstructor.d
2013-03-10 18:00:54 -04:00

27 lines
390 B
D

import std.stdio;
class Foo
{
static int count;
int f1;
this()
{
count++;
f1 = 42;
writefln("Constructed a Foo, %d exist!", count);
}
this(Foo f)
{
count++;
writefln("Copied a Foo, %d exist! f1: %d", count, f1);
}
};
void main()
{
Foo foo1 = new Foo();
Foo foo2 = new Foo();
Foo foo3 = new Foo(foo1);
}