class A {
int x, y;
void copy (in A a) {
x =
a.x;
y = a.y;
}
void dump (string s) {
writefln( "%s.A = { %s,
%s }", s, x, y);
}
}
class B : A {
int z;
void copy (in B b) {
super.copy(
b);
z = b.z;
}
void dump (string s) {
super.dump(
s);
writefln( "%s.B = { %s }", s, z);
}
}
void main () {
B foo = new B;
B bar = new B;
foo.x = 3;
foo.y = 5;
foo.z = 17;
bar.x = 7;
bar.y = 11;
bar.z = 13;
foo.dump( "foo");
bar.dump( "bar");
bar.copy( foo);
bar.dump( "bar#2");
}
Which prints:
foo.A = { 3, 5 }
foo.B = { 17 }
bar.A = { 7, 11 }
bar.B = { 13
}
bar#2.A = { 3, 5 }
bar#2.B = { 17 }