GVala added.

This commit is contained in:
Kolan Sh 2012-10-12 20:44:31 +04:00
parent 58e2f0122c
commit fd13b54b6a
1 changed files with 27 additions and 10 deletions

View File

@ -1,28 +1,45 @@
class Base : GLib.Object { class Base : GLib.Object {
public virtual void copy () { public int b;
stdout.printf ("Base copy() called\n");
public virtual void copy_from (Base b) {
stdout.printf ("Base copy_from() called\n");
this.b = b.b;
} }
} }
class Sub : Base { class Sub : Base {
public override void copy () { public int s;
stdout.printf ("Sub copy() called\n");
public override void copy_from (Base b) {
stdout.printf ("Sub copy_from() called\n");
this.s = ((Sub)b).s;
} }
} }
class SubSub : Sub { class SubSub : Sub {
public override void copy () { public int ss;
stdout.printf ("SubSub copy() called\n"); public int s;
public override void copy_from (Base b) {
stdout.printf ("SubSub copy_from() called\n");
this.ss = ((SubSub)b).ss;
//((Sub)this).copy_from(b);
} }
} }
class GVala : GLib.Object { class GVala : GLib.Object {
public static int main (string[] args) { public static int main (string[] args) {
// var base = new Base(); var src = new SubSub();
// var sub = new Sub(); src.b = 1;
Base b = new SubSub(); src.s = 2;
src.ss = 3;
b.copy(); Base b = new SubSub();
b.copy_from(src);
var ss = (SubSub) b;
stdout.printf ("b = %d, s = %d, ss = %d\n", ss.b, ss.s, ss.ss);
return 0; return 0;
} }